Originally wanted to test inheritance, there was this error:
Source
1 classA1 (object):2 deffo1 (self):3 Print "i ' m A1"4 classA2 (object):5 deffo1 (self):6 Print "i ' m A2"7 classB1 (A1,A2):8 defBar (self):9 Print "i ' m B1"Ten classB2 (A2,A1): One defBar (self): A Print "i ' m B2" - classC (B1,B2): #提示出现错误的地方 - Pass the if __name__=='__main__': -m=C () - PrintC.__mro__ - M.bar () +M.fo1 ()
The number of error rows appears in 13 lines, the actual composition of the time produced an error, (according to succession, a wide search composition)
At this point the composition is
Obviously cannot appear two A1, therefore may appear as above the error
B has a connection to a, only the following inheritance composition.
The code revision will be changed to
classA1 (object):deffo1 (self):Print "i ' m A1"classA2 (object):deffo1 (self):Print "i ' m A2"classB1 (A1,A2):defBar (self):Print "i ' m B1"classB2 (A1,A2):defBar (self):Print "i ' m B2"classC (B1,B2):Passif __name__=='__main__': M=C ()PrintC.__mro__M.bar () m.fo1 ( )
Typeerror:error when calling the Metaclass bases cannot create a consistent method resolution order (MRO) for bases A2, a 1 causes of occurrence and solutions