[Tutor] property built-in
Kent Johnson
kent37 at tds.net
Fri Oct 20 00:20:51 CEST 2006
wesley chun wrote:
>>> x= property(**x())
>>>
>>> questions:
>>> 1: why doesn't there have to be a self in x()?
>> x is not a "normal" class method. It is only used as a container to
>> hold the "real" methods which are returned in the locals() dictionary.
>
>
> on a related note, if you're using Python 2.4 and newer, you can
> simplfy your code a bit by replacing the call to property() with a
> decorator for x, as in:
>
> @property
> def x():
> :
I don't think so. This will wrap x itself as a property, equivalent to
x = property(x)
which is not the same as Lloyd's code which turns the dict returned by x
into a property:
x = property(**x())
Kent
More information about the Tutor
mailing list