新类型类中的方法解析顺序(MRO)?
class Base1(object): def amethod(self): print "Base1" class Base2(Base1): passclass Base3(object): def amethod(self): print "Base3"class Derived(Base2,Base3): passinstance = Derived() instance.amethod() print Derived.__mro__
instance.amethod()
Base1
Base3
Derived.__mro__
(<class '__main__.Derived'>, <class '__main__.Base2'>, <class '__main__.Base1'>, <class '__main__.Base3'>, <type 'object'>)
肥皂起泡泡
杨魅力
相关分类