[Tutor] Calling super classs __init__?

tiger12506 keridee at jayco.net
Sat Mar 22 17:44:18 CET 2008


So super(A, c) refers to the baseclass object?

I don't like this. It partially suggests that A is a superclass of B.
I guess I have to be sure to notice the second parameter which tells of 
which instance I'm finding the superclass.

fyi I totally didn't notice the first parameter of super... was it there in 
previous versions of python?


----- Original Message ----- 
From: "Andreas Kostyrka" <andreas at kostyrka.org>
To: "tiger12506" <keridee at jayco.net>
Cc: <tutor at python.org>
Sent: Friday, March 21, 2008 4:25 AM
Subject: Re: [Tutor] Calling super classs __init__?

class A(object):
    v=lambda self: "A"
class B(object):
    v=lambda self: "B"
class C(B,A):
    v=lambda self: "C"

print C.__mro__

c=C()
print c.v()
print super(C, c).v()
print super(B, c).v()

(<class '__main__.C'>, <class '__main__.B'>, <class '__main__.A'>, <type 
'object'>)
C
B
A 


More information about the Tutor mailing list