[Tutor] Builtin "property" decorator hiding exceptions

Andreas Kostyrka andreas at kostyrka.org
Thu Apr 19 10:27:23 CEST 2007


* 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. Basically, function
objects (methods) do the __get__ protocol that property is doing to
make the self parameter binding.

decorators, if you expect them to work like normal methods do have
certain limits what they can return.

Ever wondered why practically all (well, I did it for a closed source
contract once differently) decorators are functions that return
interior nested functions, instead of returning callable object
instances? That's why.

Andreas


More information about the Tutor mailing list