python-mro

Method resolution order in Python

Method resolution order in Python Question: 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, …

Total answers: 3