@Python新式类和经典类的区别
- class ClassicClass():
- pass
- class NewStyleClass(object):
- pass
- x1 = ClassicClass()
- x2 = NewStyleClass()
- print x1.__class__, type(x1)
- print x2.__class__, type(x2)
输出结果:
__main__.ClassicClass <type 'instance'>
<class '__main__.NewStyleClass'> <class '__main__.NewStyleClass'>
经典类的继承是深度优先,新式类的继承是广度优先。