What is "self"?

Michael Spencer mahs at telcopartners.com
Tue Sep 27 13:20:10 EDT 2005


Ron Adam wrote:
> What I've noticed is you can block the visibility of a class attribute, 
> which include methods, by inserting an object in the instance with the 
> same name.
> 
[snip example of this behavior]

Yes, that's true for "non-data descriptors" (see last two bullets below)

Raymond Hettinger [http://users.rcn.com/python/download/Descriptor.htm]
 >
 > The important points to remember are:
 >
 >     * descriptors are invoked by the __getattribute__ method
 >     * overriding __getattribute__ prevents automatic descriptor calls
 >     * __getattribute__ is only available with new style classes and objects
 >     * object.__getattribute__ and type.__getattribute__ make different calls 
to __get__.
 >     * data descriptors always override instance dictionaries.
 >     * non-data descriptors may be overridden by instance dictionaries.

Michael




More information about the Python-list mailing list