Reputation: 175
An order object have different task objects, within each task I need to keep track of the order also. Indeed, I will define different orders later. I defined the following classes.
How to fix this?
Upvotes: 1
Views: 153
Reputation: 392
You have a property and class attribute with the same name in the Task
class. Since you haven't defined a setter for the command
property, you get this error.
To fix this, you should probably make the Task
class store the command in an attribute with a different name and add a setter, perhaps something along the lines of:
class Task:
def __init__(self, ..., command):
# some init stuff ...
self._command = command
@property
def command(self):
# sanity check here...
return self._command
@command.setter
def command(self, x):
self._command = x
Or if you don't want the command property changed after the task is created, just leave out the setter.
Upvotes: 2