I'm trying to code a very rudimentary GTD app for myself, not only to get organized, but to get better at coding and get better at Python. I'm having a bit of trouble with the classes however.
Here are the classes I have so far:
class Project:
def __init__(self, name, actions=[]):
self.name = name
self.actions = actions
def add(self, action):
self.actions.append(action)
class Action:
def __init__(self, do='', context=''):
self.do = do
self.context = context
Each project has actions to it, however I want to make it so that projects can also consist of other projects. Say daily I wanted to print out a list of everything. I'm having trouble coming up with how I would construct a list that looked like this
> Project A
> Actions for Project A
> Project B
> Sub project A
> Actions for Sub project A
> Sub project B
> Actions for Sub project B
> Sub project C
> Sub sub project A
> Actions for sub sub project A
> Sub sub project B
> Actions for sub sub project B
> Actions for Sub project C
> Actions for Project B
It's quite clear to me that recursion is going to be used. I'm struggling with whether to create another class called SubProject and subclass Project to it. Something there just makes my brain raise an exception.
I have been able to take projects and add them to the actions attribute in the Project class, however then I run into where MegaProject.actions.action.actions.action situations start popping up.
If anyone could help out with the class structures, it would be greatly appreciated!