Message161980
| 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 | 猫.黒 | set | recipients:
+ 猫.黒 |
| 2012年05月31日 03:04:01 | 猫.黒 | set | messageid: <1338433441.66.0.975494137492.issue14965@psf.upfronthosting.co.za> |
| 2012年05月31日 03:04:00 | 猫.黒 | link | issue14965 messages |
| 2012年05月31日 03:04:00 | 猫.黒 | create |
|