Method resolution order in python
问题 I am new to python. I am using python 2.7. I was going through method order resolution with a small snippet as follows: class A(object): attr = 'A' class B(A): pass class C(A): attr = 'C' class D(B,C): pass x = D() print x.attr The order of resolution is x,D,B,C,A and hence the output would be C. Going by the above example, i made a small change to the code. class A(object): attr = 'A' class E(object): attr = 'E' class B(A): pass class C(E): attr = 'C' class D(B,C): pass x = D() print x.attr