Problems with properties
Benji York
benji at benjiyork.com
Fri Oct 14 11:59:25 EDT 2005
Michael Schneider wrote:
> The get property access is working, but the the set
> property is not working.
The classes need to be "new style" for properties to work right. Just
change "class Task:" to "class Task(object):".
Your "setNothing" method is unnecessary, if you don't proved a "setter"
an exception will be raised automatically. Also (if you're using Python
2.4) you probably want to look at decorator syntax.
So you're class could look like this:
class Task(object):
def __init__(self,command):
self._command = command
@property
def command(self):
return self._command
--
Benji York
More information about the Python-list
mailing list