仅作记录之用。
更多细节:How does Python's super() work with multiple inheritance?
代码一:
# coding: utf-8
class A:
def __init__(self):
print('A')
self.name = 'A'
def echo(self):
print('name: %s' % self.name)
class B:
def __init__(self):
print('B')
class C(B, A):
def __init__(self):
super().__init__()
print('C')
c = C()
代码二:
# coding: utf-8
class A:
def __init__(self):
print('A')
self.name = 'A'
def echo(self):
print('name: %s' % self.name)
class B(A):
def __init__(self):
super().__init__()
print('B')
class C(B, A):
def __init__(self):
super().__init__()
print('C')
c = C()
网友评论