Message161980
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' |
|
| Date |
User |
Action |
Args |
| 2012-05-31 03:04:01 | 猫.黒 | set | recipients:
+ 猫.黒 |
| 2012-05-31 03:04:01 | 猫.黒 | set | messageid: <[email protected]> |
| 2012-05-31 03:04:00 | 猫.黒 | link | issue14965 messages |
| 2012-05-31 03:04:00 | 猫.黒 | create | |
|