Immutability
Bruno Desthuilliers
bdesth.quelquechose at free.quelquepart.fr
Wed Jun 28 22:16:23 EDT 2006
Georg Brandl a écrit :
> Nick Maclaren wrote:
>
>>In article <mailman.7574.1151511089.27775.python-list at python.org>,
>>"Fredrik Lundh" <fredrik at pythonware.com> writes:
>>|>
>>|> identical? you only applied @property to one of the methods, and then you're
>>|> surprised that only one of the methods were turned into a property?
>>
>>I wasn't expecting EITHER to be turned INTO a property - I was expecting
>>both methods to be the same, but one would have non-default properties
>>attached to it.
>
>
> That's another sign that property isn't intended to be used as a decorator.
> Normally, decorators wrap functions with other functions.
Normally, decorators take a function and return anything appropriate.
> property doesn't
> return a function but a descriptor object.
FWIW, function *are* descriptors (well, Python functions at least, cf
the recent thread about pyrex functions).
>>> def fun(): pass
...
>>> fun.__get__
<method-wrapper object at 0x4041e1ec>
>>>
More information about the Python-list
mailing list