[Tutor] Builtin "property" decorator hiding exceptions

Kent Johnson kent37 at tds.net
Thu Apr 19 12:31:58 CEST 2007


Andreas Kostyrka wrote:
> * Jacob Abraham <jakieabraham at yahoo.com> [070419 10:08]:
>> Hi Andreas Kostyrka,
>>
>>    I am aware that property is a data descriptor. And I still don't see why if can't be uses as a decorator since decorators were created to fix the issue.
>>
>> getx= property(getx)
> 
> Simple, they don't return function objects.

That is not a requirement, afaik. classmethod() and staticmethod() don't 
return function objects either and they are usable as decorators.

@property
def foo()...

is equivalent to
def foo()...
foo = property(foo)

which is the usual usage.

To argue from authority :-) Ian Bicking agrees with me:
http://blog.ianbicking.org/property-decorator.html

Kent


More information about the Tutor mailing list