FAQ

Leif K-Brooks wrote:

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:

class A(object):
def do_stuff(self):
print "A is doing stuff now."


class B(A):
def do_stuff(self):
super(B, self).do_stuff()
print "B is doing stuff now."


class C(B):
def do_stuff(self):
super(C, self).do_stuff()
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.
What's the going argument against it? Makes sense to me.

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 8 of 11 | next ›
Discussion Overview
grouppython-list @
categoriespython
postedOct 15, '04 at 2:52p
activeOct 16, '04 at 10:11a
posts11
users9
websitepython.org

People

Translate

site design / logo © 2022 Grokbase