'property' builtin does not work for me
Alex Fainshtein
alex_fainshtein at netzero.net
Fri May 2 17:29:57 EDT 2008
Question: what I am doing wrong? Here, I am defining class with property
member:
class Test:
def getter(self):
print "Getter called."
return 'a'
def setter(self, val):
print "Setter called."
prop = property(getter, setter)
Then testing it:
>>> t = Test()
>>> t.prop
Getter called.
'a'
>>> t.prop = 'b'
>>> t.prop
'b'
>>>
As you see, getter works properly. But when assigning to property, setter is
not called, as I would expect. prop is simply replaced with whatever is
assigned and ceased being a property.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20080502/a98d8695/attachment.html>
More information about the Python-list
mailing list