python class各承接关系

以下例子可以通过python 的编译器进行打印理解python class间的承接关系

class A(object):
        def _init_(self):
             self.a = 1

        def x(salf):
             print "A.x"
        def y(self):
             print "A.y"
        def z(self):
             print "A.z"

class B(A):
         def _init_(self):
              A._init_(self)
               self.a = 2
               self.b = 3
         def y(self):
               print "B.y"
         def z(self):
               print "B.z"

class C(object):
         def _init_(self):
              self.a = 4
              self.c = 5
        def y(self):
              print "C.y"
        def z(self):
              print "C.z"

class D(C,B):
        def _init_(self):
             C._init_(self)
             B._init_(self)
             self.d = 6
        def z(self):
              print "D.z"

你可能感兴趣的:(python class各承接关系)