Why does super() require the class as the first argument?

Delaney, Timothy C (Timothy) tdelaney at avaya.com
Sun Feb 6 18:39:55 EST 2005


Nick Coghlan wrote:

> It *is* possible to eliminate the explicit class argument, but it
> takes a bit (*cough*) of work:
> http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/286195

Nick - you stole my thunder ;)

Note that my recipe uses a sys._getframe() hack, so it will never be in
Python as it is. It's also considerably slower than just using super.
But it *does* eliminate the need for specifying the current class name,
and (if you wish) the current method name.

Guido has said that eventually he wants a simpler super() call - but he
doesn't really like my proposed syntax of having it hang off self.
Personally, I like it though and if there was enough community support
I'd write it up as a PEP using the recipe as a sample implementation
which demonstrates the required semantics. However, it hasn't gained
much community support so far ;)

Tim Delaney



More information about the Python-list mailing list