class Base:
pass
class F1:
def f1(self):
pass
class F2(Base):
def f2(self):
pass
class F3(F1):
def f3(self):
pass
class F4(F2):
def f4(self):
pass
class Son(F4, F3):
pass
obj = Son()
obj.f1()
#左侧优先
#左侧路径到最后
F4 --> F2 --> Base
F3 --> F1
class Base:
pass
class F1(Base):
def f1(self):
pass
class F2(Base):
def f2(self):
pass
class F3(F1):
def f3(self):
pass
class F4(F2):
def f4(self):
pass
class Son(F4, F3):
pass
obj = Son()
obj.f1()
#有同一个基类时,基类最后执行
F4 --> F2
F3 --> F1
Base
class F1:
def f1(self):
#self是Son的对象,所以调用f4()方法的时候,是重新以左侧优先、左侧路径到最后的逻辑开始查找的
self.f4()
def f4(self):
print('there!')
class F2:
def f2(self):
pass
class F3(F1):
def f3(self):
pass
class F4(F2):
def f4(self):
print('here!')
class Son(F4, F3):
pass
obj = Son()
obj.f1()
F4 --> F2
F3 --> F1
F4 --> 打印here!