Using metaclasses to make super more beatiful

Just just at xs4all.nl
Fri Jun 6 03:54:55 EDT 2003


In article <mailman.1054855311.16882.python-list at python.org>,
 Gerrit Holl <gerrit at nl.linux.org> wrote:

> > > Tip: create a class C, derived from B, then call f() on an instance of 
> > > C, and see what happens <wink>.
> > 
> > RuntimeError: maximum recursion depth exceeded
> > 
> > Hmm, I thought I understood it but I apparantly don't, since I don't
> > see why this happens... 

What happens is that your super attr is always the super class of the 
instance, but what you need is the super class of the class in which the 
method is defined.

> I don't get it. What is the essential difference between this and
> Guido's example on http://www.python.org/2.2.3/descrintro.html#metaclasses?

Guido uses a "private" attribute __super, which does the right thing due 
to name mangling: "__super" gets mangled to "_ClassName__super", so each 
class has its own private __super.

Just




More information about the Python-list mailing list