Python学习之路:新式类VS经典类

class Person(object):#新式类
    super


class Person:#经典类
    Person.__init__

#多继承时,顺序的区别--新式类和经典类:在Python3.X中广度查找;在Python2.X中新式类采用广度查找,经典类采用深度查找

class A(object):
    pass
    # def __init__(self):
    #     self.n = "A"

class B(A):
    pass
    # def __init__(self):
    #     self.n = "B"

class C(A):
    def __init__(self):
        self.n = "C"

class D(B,C):
    pass
    # def __init__(self):
    #     self.n = "D"


d = D()
print(d.n)

 

posted @ 2018-01-23 11:29  Py小白  阅读(178)  评论(0编辑  收藏  举报