[Python-3000] Fixing super anyone?

Phillip J. Eby pje at telecommunity.com
Mon Apr 23 23:31:31 CEST 2007

At 11:08 PM 4/23/2007 +0200, Michele Cella wrote:
>My solution is nice (IMHO) for the simplest use case (and, probably, the
>most frequent) but it's behavior is really unclear for these complex use
>cases. Thanks for pointing that out.
>As far as I'm concerned, I can only confirm that having a super keyword
>with methods attached (like Aahz said) when no other keyword has (and
>there are many) doesn't feel right (to me) and can be confusing at
>first. That's unfortunate as I rarely found python confusing up to now
>(contrary to other languages).
>The only other option that comes to my mind is using a special attribute
>in the instance itself (like __class__, __dict__, ...):
>         self.__super__.mymethod(arg)
>I'm sure this (again) introduces other problems I simply overlooked, in
>this case, forgive me please. ;-)

One other option that's been used more and more lately are parentheses, as in:

    (super self).foo()

But I can't say I particularly like this idea, compared to "super.foo" or 
even "super(self).foo".  In fact, the latter invocation doesn't even 
require a keyword -- it just means the compiler needs to include a cell 
variable for the current class whenever it thinks you might be using super().

More information about the Python-3000 mailing list