given below python program .
class FooBase(object):
def foo(self): pass
class A(FooBase):
def foo(self):
super(A, self).foo()
print 'A.foo()'
class B(FooBase):
def foo(self):
super(B, self).foo()
print 'B.foo()'
class D(B):
def foo(self):
super(D, self).foo()
print 'D.foo()'
class C(A,D,B):
def foo(self):
super(C, self).foo()
print 'C.foo()'
c=C()
c.foo()
output is
B.foo()
D.foo()
A.foo()
C.foo()
but when i ran below program
class A1(object):
def get(self):
print 'A1'
class A2(object):
def get(self):
print 'A2'
class A3(object):
def get(self):
print 'A3'
class B2(A2):
def get(self):
super(B2,self).get()
print 'b2'
class B3(A3):
def get(self):
super(B3,self).get()
print 'b3'
class C3(B3):
def get(self):
super(C3,self).get()
print 'c3'
class Foo(C3, A1, B2):
def get(self):
super(Foo,self).get()
print 'Foo'
#print Foo.__mro__
Foo().get()
when i excuted the above i got the output as below
output
A3
b3
c3
Foo
the question why does the A1.get()
and B2.get()
was not called.is there any wrong with the calling of super?
i was expecting the output
A3
b3
c3
A1
A2
b2
Foo
Edit: if anyone explain what is difference between first and second example would be great:)