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

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.