[Tutor] __getattr__(): Is this right?

Allen Fowler allen.fowler at yahoo.com
Tue Oct 16 05:12:31 CEST 2007




> "Note that if the attribute is found through the normal mechanism, 
> __getattr__() is not called. (This is an intentional asymmetry between 
> __getattr__() and __setattr__().) This is done both for efficiency 
> reasons and because otherwise __setattr__() would have no way to 
> access other attributes of the instance."

There you go, you are right and I am not.  I guess because I don't 
actually set the attribute of self, I can intercept both the get and set.

"Learn one new thing every day".   Done.  :-)

Happy to help.... :)

You may be interested in:
__getattribute__
http://docs.python.org/ref/new-style-attribute-access.html

That will get ALL requests.
 Read the warnings, though.




       
---------------------------------
Tonight's top picks. What will you watch tonight? Preview the hottest shows on Yahoo! TV.    
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20071015/34aa06b3/attachment.htm 


More information about the Tutor mailing list