Setter Propertys' mro?
cipher
cipherzero at gmail.com
Sat Sep 6 21:15:33 EDT 2008
Whats the mro (method resolution order) of a setter property (__set__
on a descriptor).
i seem to be experiencing some weird issue with them.
for example
>>> class test:
... def _test(self):
... return 4
... def _stest(self):pass # dont change value
... def _dtest(self,value):pass
... p=property(_test,_stest,_dtest)
>>> t=test()
>>> t.p
4
>>> t.p=5
>>> t.p
5
Why is that being 'overridden' ( by that i mean that it is storing
that value in t's __dict__)
>>> t.__dict__
{'t': 5}
why DIDNT the setter get hit?
however, if i specify the metaclass in the class definition it works
just fine...
class test:
__metaclass__=type
def _test(self):
return 4
def _stest(self,value):pass # dont change value
def _dtest(self):pass
p=property(_test,_stest,_dtest)
>>> t=test()
>>> t.p
4
>>> t.p=5
>>> t.p
4
why do i have to set the __metaclass__ ? this seems like a bug?
i know that i probably shouldn't worry about this because if a
programmer does want to set my value and it causes an error, thats his
problem.... but this bothers me. whats the point of the __set__ method
then?
Thanks in advanced.
--
Cipher
More information about the Python-list
mailing list