class Item:
    def __init__(self, id, content, userid, duedate, collapsed, inhistory, priority, itemorder, faded, projectid, checked, datestring): = id
        self.content = content
        self.userid = userid
        self.duedate = duedate
        self.collapsed = collapsed
        self.inhistory = inhistory
        self.priority = priority
        self.itemorder = itemorder
        self.faded = faded
        self.projectid = projectid
        self.checked = checked
        self.datestring = datestring
    def __str__(self):
        return self.content

class Project:
    def __init__(self, id, name, userid, color, collapsed, itemorder, indent, order): = id = name
        self.userid = userid
        self.color = color
        self.collapsed = collapsed
        self.itemorder = itemorder
        self.indent = indent
        self.order = order
        self.items = {}
    def __str__(self):

    def __name__(self):
        return 'Project'
    def addItem(self,item):

    def delItem(self,item):
        del self.items[]

class TodoList:
    def __init__(self):
        self.projects = {}

    def addProject(self,project):

    def delProject(self,project):
        del self.projects[]

    def addItem(self,item):

    def delItem(self,item):

Some of the above code is changing as we speak but I am curious if I should make the projects dict and items dicts private and use accessor functions to move items between projects or change the attributes of a project or item.

Another thought is to have items and projects both be members of TodoList as I am provided with the Item's project ID when I get the Item, so I could just have a method that returned all the items with a given project ID and not bother with separating them into the individual projects.

I am just trying to design the best I can as I plan on using this app as an example of my Python coding ability, though I just started with python about 3 days ago.

We do not make private attributes in python, except in very rare cases. You can shadow the attribute access with "property" decorator later.

The Item and the Project class is trying to reimplement the named tuple, which is present in python 2.6 or later.

From a design point of view I find it unfortunate, that you provide interface in the TodoList to add an item to a project.

Another problem is that you do not have any Item without Project. So Items aggregate (in uml sense) to a Project.

It is unforunate too, that your TodoList.addItem calls the items project to add the item to its own project:)

This article has been dead for over six months. Start a new discussion instead.