Message57345
Here's an implementation of the idea I floated recently on python-dev
(Subject: Declaring setters with getters). This implements the kind of
syntax that I believe won over most folks in the end:
@property
def foo(self): ...
@foo.setter
def foo(self, value=None): ...
There are also .getter and .deleter descriptors. This includes the hack
that if you specify a setter but no deleter, the setter is called
without a value argument when attempting to delete something. If the
setter isn't ready for this, a TypeError will be raised, pretty much
just as if no deleter was provided (just with a somewhat worse error
message :-).
I intend to check this into 2.6 and 3.0 unless there is a huge cry of
dismay. Docs will be left to volunteers as always. |
| File name |
Uploaded |
|
propset.diff
|
gvanrossum,
2007-11-10.05:58:08
|
|
| Date |
User |
Action |
Args |
| 2007-11-10 05:58:11 | gvanrossum | set | spambayes_score: 0.188865 -> 0.188865 recipients:
+ gvanrossum |
| 2007-11-10 05:58:10 | gvanrossum | set | spambayes_score: 0.188865 -> 0.188865 messageid: <1194674290.8.0.853140061818.issue1416@psf.upfronthosting.co.za> |
| 2007-11-10 05:58:10 | gvanrossum | link | issue1416 messages |
| 2007-11-10 05:58:08 | gvanrossum | create | |
|