super() and __get__

Mike Dean klaatu at evertek.net
Wed Nov 27 10:46:21 EST 2002


These are probably two separate questions, but...

I was out on Guido's page on Unifying Types and Classes, trying to grok 
super(), metaclasses, and th meaning of life.  I think I get this 
metaclass thing, but let me see if I get this right on super() - all 
super() does, is create an object that responds to attribute access by 
passing that access on to the first object (class, type, whatever) in 
the MRO of the object with which super() was called, starting with the 
type super() was called with (i.e., if class C has 10 base classes & 
types, once all flattened out into the MRO, and class B is the 4th in 
the MRO, then it only searches from B on).  Am I correct?

Now, a couple more questions...

Where did this __get__ thing used in describing super() (and another 
thing or two on that page) come from?  I can't seem to find it in the 
docs anywhere.  It was used in the Python Super() implementation, as 
well as another time or two.

Also, if object is the base class of type, why does object.__mro__ work 
when object defines no __mro__?

And finally, since __mro__ appears to be an attribute merely inherited 
from type by all classes, if I have a fancy, can I override __mro__ to 
suit some bizarre purpose?  Or is it ignored, simply a mechanism to 
access __mro__?  Likewise, why does type also have an mro method, when 
there's __mro__?

Thanks to any who can enlighten me,
Mike



More information about the Python-list mailing list