类多继承C3算法

class H:
    def bar(self):
        print("F.bar")


class G(H):
    def bar(self):
        print("F.bar")


class F(H):
    def bar(self):
        print("F.bar")


class E(G):
    def bar(self):
        print("E.bar")


class D(F):
    def bar(self):
        print("D.bar")


class C(E):
    def bar(self):
        print("C.bar")


class B(D):
    def bar(self):
        print("B.bar")


class A(B, C, D):
    def bar(self):
        print("A.bar")


a = A()
print(A.mro())
# 结果
# [<class '__main__.A'>, <class '__main__.B'>, <class '__main__.C'>, <class '__main__.D'>, <class '__main__.F'>, <class '__main__.E'>, <class '__main__.G'>, <class '__main__.H'>, <class 'object'>]

是按照C3算法来的
下面是推倒的过程

上一篇:微信小程序 实现搜索框功能


下一篇:javascript作用域闭包