class Base(object):
def __init__(self):
print('Base __init__', self)
def f(self):
print('Basef')
class AA(Base):
super().__init__()
print('AA __init__', self)
super().f()
print('AAf')
class A(Base):
print('A __init__', self)
print('Af')
class B(Base):
super(B, self).__init__()
print('B __init__', self)
print('Bf')
class C(B, AA, A):
print('C __init__', self)
print('Cf')
def __str__(self):
return 'This is an instance of class C'
c = C()
c.f()
Sign in to make a reply
郁闷~喝可乐
class Base(object):
def __init__(self):
print('Base __init__', self)
def f(self):
print('Basef')
class AA(Base):
def __init__(self):
super().__init__()
print('AA __init__', self)
def f(self):
super().f()
print('AAf')
class A(Base):
def __init__(self):
super().__init__()
print('A __init__', self)
def f(self):
super().f()
print('Af')
class B(Base):
def __init__(self):
super(B, self).__init__()
print('B __init__', self)
def f(self):
super().f()
print('Bf')
class C(B, AA, A):
def __init__(self):
super().__init__()
print('C __init__', self)
def f(self):
super().f()
print('Cf')
def __str__(self):
return 'This is an instance of class C'
c = C()
c.f()