Why does super take a class name as the argument?
eurleif at ecritters.biz
Fri Oct 15 22:27:13 CEST 2004
Chris Green wrote:
> I've done a bit of searching in the language reference and a couple
> pages referring the behavior of super() but I can't find any
> discussion of why super needs the name of the class as an argument.
Think about it. In this code:
print "A is doing stuff now."
print "B is doing stuff now."
print "C is doing stuff now."
How would Python know that B should call C's do_stuff() method instead
of its own if there was no class argument? The self argument would be
exactly the same when C called super() as when B called it. There has
been some talk of making super into a language keyword instead of a
type, though; that would eliminate the need to even pass in self.
More information about the Python-list