From: Gregory Ewing on
Steven D'Aprano wrote:

> super() is just as explicit as len(), or str.upper(). It says,
> explicitly, that it will call the method belonging to one or more
> superclass of the given class.

That's not strictly true. It will call a method belonging to some
class in the mro of self, but that class is not necessarily in
the base list of the class mentioned in the super() call. It's
possible for a super() call to go "sideways" in the inheritance
graph.

--
Greg
From: Gregory Ewing on
Steven D'Aprano wrote:
> On Thu, 29 Jul 2010 19:29:24 +0200, Jean-Michel Pichavant wrote:
>
>>"mro" would have been the proper name for "super".
>
> That's your opinion. In any case, whether super() was called super() or
> mro() or aardvark() makes no difference to the functionality or whether
> it is useful.

I think the point is that the name is misleading, because it
makes it *sound* like it's going to call a method in a superclass,
when it fact it might not.

--
Greg
From: Gregory Ewing on
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
From: Gregory Ewing on
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