Problems with properties
shawn
google at shawndyer.com
Fri Oct 14 12:04:03 EDT 2005
I was thinking that in Python2.4, all class definitions inherited from
new-style classes. There may be a bug here. I can make your code work
as expected by changing the class definition to:
class Task(object):
with that change, the assignment raises an attribute error. You could
also accomplish the same thing by eliminating the setNothing method and
defining your property as:
command=property(getCommand)
or for a really simple case like this, you could even leave off the
getCommand function and define the property as:
command=property(lambda self: self._command)
(although I am sure personal tastes vary as to style here).
More information about the Python-list
mailing list