Author 猫.黒
Recipients 猫.黒
Date 2012-05-31.03:04:00
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1338433441.66.0.975494137492.issue14965@psf.upfronthosting.co.za>
In-reply-to
Content
super() objects allow access to inherited properties fget() but not fset() or fdel(), resulting in unexpected behavior.

Today on pydev thread 'Property inheritance in Python' GvR said "I
don't see the need for a Python-Ideas detour. It seems worth fixing"

>>> class BaseProp(object):
...     @property
...     def p(self):
...         return self._p
...     @p.setter
...     def p(self, value):
...         self._p = value
>>> class DerivedProp(BaseProp):
...     @property
...     def p(self):
...         return super(DerivedProp, self).p * 2
...     @p.setter
...     def p(self, value):
...         super(DerivedProp, self).p = value / 2
>>> d = DerivedProp()
>>> d._p = 21
>>> d.p
42
>>> d.p = 50
Traceback (most recent call last):
   ...
AttributeError: 'super' object has no attribute 'p'
History
Date User Action Args
2012-05-31 03:04:01猫.黒setrecipients: + 猫.黒
2012-05-31 03:04:01猫.黒setmessageid: <1338433441.66.0.975494137492.issue14965@psf.upfronthosting.co.za>
2012-05-31 03:04:00猫.黒linkissue14965 messages
2012-05-31 03:04:00猫.黒create