Immutability
Sion Arrowsmith
siona at chiark.greenend.org.uk
Wed Jun 28 10:03:29 EDT 2006
Fredrik Lundh <fredrik at pythonware.com> wrote:
>Sion Arrowsmith wrote:
>> What I've not seen documented anywhere is the:
>> @property
>> def fset(self, value):
>> ...
>> idiom. It's not obvious from the documentation of the property
>> function that it can be used as a decorator like this.
>probably because it cannot be used in that way: the "property" function
>takes the *getter* as its first argument, so you can only use this for read-
>only properties...
Ahem. Yes. What I obviously meant to write was:
What I've not seen documented anywhere is the:
@property
def fget(self):
...
idiom. [ ... ]
(As correctly written by someone else further upthread.) It is possible
to find it described by Googling, but the Cookbook (and python.org) hits
provide much more complicated general-purpose (ie setters as well)
property decorators.
--
\S -- siona at chiark.greenend.org.uk -- http://www.chaos.org.uk/~sion/
___ | "Frankly I have no feelings towards penguins one way or the other"
\X/ | -- Arthur C. Clarke
her nu becomeþ se bera eadward ofdun hlæddre heafdes bæce bump bump bump
More information about the Python-list
mailing list