PyQt4: Which one of these would be better/more correct? (Notepad++ clone)
Question: I'm making a super simple Notepad++ clone in Python/PyQt4, and I'm wondering
which of these options of storing editor tab data:

OPTION 1: I have a class called QQCodeTab, which stores the current
Qsci.QsciScintilla instance for the current tab, the file path, current
language, etc. These are mapped to tab indexes by a dict.

OPTION 2: Same as OPTION 1, but cut out the class and store everything in a
dict instead (example: `{1: {"scintilla": <blah>, "filepath":
"C:/File/whatevs.py"}, "language": "python"}`)

My code comments can explain it better.

    
    
    from PyQt4 import QtGui, Qsci
    
    class QQCodeEditor(QtGui.QTabWidget):
        def __init__(self, parent=None):
            QtGui.QTabWidget.__init__(self, parent)
            self.new_tab()
            self.new_tab()
            # Option 1: Maps index to tab object
            # Option 2: Maps index to dict of options
            self.tab_info = {}
    
        def new_tab(self):
            scin = Qsci.QsciScintilla()
            index = self.addTab(scin, "New Tab")
    
        def get_tab_info(self, index):
            # Returns QQCodeTab object
            return self.tab_info[index]
    
        def save(self, index):
            # Option 2: Save dialog boc and file system stuff goes here
            pass
    
    class QQCodeTab(object):
        def __init__(self, scintilla, editor):
            self.scintilla = scintilla
            self.editor = editor
    
        def save(self):
            # Option 1: Save dialog box and file system stuff goes here
            pass
    


Answer: If you're wondering whether to use a class of dictionary, you probably want a
`namedtuple`. That gives you the simplicity of a `dict` with the attribute
syntax of a class:

    
    
    from collections import namedtuple
    
    FooBar = namedtuple("FooBar", ["these", "are", "the", "attributes"])
    
    FooBar(123, 324, the=12, attributes=656).these
    #>>> 123
    

