标签:优先 广度优先 继承 pass print class python python3 查看
class P1:
pass
class P2:
pass
class P3:
pass
class A(P1, P2):
pass
class B(P1, P3):
pass
class C(P3, P2):
pass
class D(A, B, C):
pass
d = D()
print(D.__mro__)
# 查看 D类的多重继承的搜索顺序: D.__mro__
#python3中都是新式类,遵循的搜索原则是 广度优先
(<class ‘__main__.D‘>, <class ‘__main__.A‘>, <class ‘__main__.B‘>, <class ‘__main__.P1‘>, <class ‘__main__.C‘>, <class ‘__main__.P3‘>, <class ‘__main__.P2‘>, <class ‘object‘>)
标签:优先 广度优先 继承 pass print class python python3 查看
原文地址:https://www.cnblogs.com/kevin1220/p/14427783.html