Hi all,
I'm trying to write a small todo list/task manager and I'm having
trouble creating the right data structure to hold the tasks. The
program should have a command line interface.
This is what I want it to do:
* A list of tasks, where each task has a number of attributes.
Each task should be able to have subtasks.
* Persistence.
* A way to display all the tasks, with subtasks indented.
* A way to filter/search on the attributes of the tasks.
What I've tried so far is something like this:
<snip>
class Task(object):
def __init__(self, cargo, children=[]):
self.cargo = cargo
self.children = children
def __str__(self):
s = '\t'.join(self.cargo)
return s
def add_child(self,child):
self.children = self.children + [child]
<snip>
cargo is a list of the attributes of the task, such as task text,
status, deadline etc
What I'm having trouble with is:
* What data structure should all the Task instances be held in?
* How to traverse all the tasks, both with recursion into the subtasks
and not. I need the traversal both to create a nice string with the
task information for printing (here I need level-aware indentation),
and to be able to search the tasks by their attributes.
I suspect what I need is a tree, but I want one with multiple roots. I
only envision having <100 tasks at any one time so I don't need a
database backend. Persistence I think I've solved by having the
container data structure dump/load itself using pickle.
Best regards,
Alexander
_______________________________________________
Tutor maillist - [email protected]
http://mail.python.org/mailman/listinfo/tutor