Thursday, October 21, 2010

[Level 3] Method Resolution Order in Python

If you want to know the ordering of the method, you can check from __mro__.
Ex.
>>> class c11(object):
...   pass
...
>>> class c12(object):
...   pass
...
>>> class c21(object):
...   pass
...
>>> class c22(object):
...   pass
...
>>> class c1(c11,c12):
...   pass
...
>>> class c2(c21,c22):
...   pass
...
>>> class c(c1,c2):
...   pass
...
>>> c.__mro__
(, , , , , , , )
>>>

Wish this helps.
regards,
Stanley Huang