<span style="font-size:18px;">#从Python的内置类中派生的都是python的新式类 #新式类会广度搜索,也就是一层层的向上搜索 class A(object): attr=1 class B(A): pass class C(A): attr=3 class D(B,C): pass #经典类会深度搜索,遇到一个超类节点向上搜索 class ClassicA: attr=1 class ClassicB(ClassicA): pass class ClassicC(ClassicA): attr=3 class ClassicD(ClassicA): pass if __name__ == "__main__": d = D() print "attr=", d.attr #attr=3 cd = ClassicD() print "attr=", cd.attr #attr=1 </span>
原文地址:http://blog.csdn.net/davidsu33/article/details/41941757