Dynamic use of property() fails

Bruno Desthuilliers bruno.42.desthuilliers at websiteburo.invalid
Tue Apr 15 04:44:45 EDT 2008


Hrvoje Niksic a écrit :
(snip)
> As others explained, descriptors are called for descriptors found in
> class attributes, not in ones in instance attributes.  
(snip)

> However, if you know what you're doing, you can simply customize your
> class's __getattribute__ to do what *you* want for your objects.

<op>
But bear in mind that, beside possible unwanted side-effectn, you'll get 
  a non-negligible performance hit - __getattribute__ being, as the name 
implies, invoked on each and every attribute lookup.

FWIW, I tried this approach once, and quickly came back to a simpler 
solution.

</op>
(snip code)



More information about the Python-list mailing list