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 04:21:08 EDT 2010


Steven D'Aprano wrote:

> super(C, self)
> 
> shouldn't be interpreted as "call C's superclasses from self". It means 
> "starting just after C in the MRO, call self.__class__'s superclasses".

My contention is that nobody has any chance of guessing what
it does based on the name "super". Superness doesn't come into
it at all, except in the trivial sense that whatever class it
picks will be in the mro of the second argument, which doesn't
narrow it down much.

So the word "super" here is little better than meaningless noise.

If it were something like next_method(C, self) then one could
claim with some justification that it stands for "call the next
method found after C in the mro of self".

-- 
Greg



More information about the Python-list mailing list