MRO is the method resolution order, which is used primarily to determine the path of a property that is tuned at multiple inheritance (from which class).
http://blog.csdn.net/imzoer/article/details/8737642
Do you really understand the MRO algorithm in Python?
Api:
1 classtype (object):2 """3 type (object), the object ' s type4 type (name, bases, Dict), a new type5 """6 defMRO (self):#real signature unknown; restored from __doc__7 """8 MRO () List9 return a type ' s method resolution orderTen """ One return[]
Test code:
1 #!/usr/bin/env python2 classA (object):3 def __init__(self):4 Print "Enter A"5 Print("Leave A")6 7 8 classB (object):9 def __init__(self):Ten Print "Enter B" One Print "Leave B" A - - classC (A, b): the def __init__(self): - Print "Enter C" -Super (C, self).__init__() - Print "Leave C" + -b =C () +Mo = B.__class__. MRO () A PrintMo
Output:
Enter C
Enter A
Leave A
Leave C
[<class ' __main__. C ';, <class ' __main__. A ';, <class ' __main__. B ';, <type ' object ';]
Method parsing Order (MRO) for Python