首页 > 代码库 > super的用法

super的用法

class A(object):
    def __init__(self):
        print( "enter A")
        print ("leave A")

class B(object):
    def __init__(self):
        print ("enter B")
        print ("leave B")

class C(A):
    def __init__(self):
        print ("enter C")
        super(C, self).__init__()
        print ("leave C")

class D(A):
    def __init__(self):
        print ("enter D")
        super(D, self).__init__()
        print ("leave D")
class E(B, C):
    def __init__(self):
        print ("enter E")
        B.__init__(self)
        C.__init__(self)
        print ("leave E")

class F(E, D):
    def __init__(self):
        print ("enter F")
        E.__init__(self)
        D.__init__(self)
        print ("leave F")

  

super的用法