Builtn super() function. How to use it with multiple inheritance? And why should I use it at all?

Gregory Ewing greg.ewing at canterbury.ac.nz
Sun Aug 1 03:13:18 CEST 2010


Steven D'Aprano wrote:

> Assuming you accurately tell it the current class, can you give an 
> example where super() doesn't refer to a superclass of the current class?

I think we're all confusing each other in this discussion
by not being clear enough about what we mean by the "current
class".

In a call super(C, self), there are two possible things it
could mean: the class C, or the type of self.

Obviously it will return some class in the mro of self,
but as Brian Victor's example demonstrates, it *doesn't*
necessarily return a class in the mro of C.

-- 
Greg



More information about the Python-list mailing list