Multiple inheritance like Python

Source: Internet
Author: User
Class A (object):    def test_func (self):        print (' From A ') class B (A):    Pass    # def test_func (self):    #     print ("From B") class C (A):    Pass    # def test_func (self):    #     print ("from C") #多继承, 2.7 and 3.0 is a bit different, 2.7 of the classic class is depth first, 3.0 of the classic class is also the breadth first, 3.0 of the new class is also the breadth first, such as Class D inherits C class and Class B, and C class and Class B inherit Class A # If there is a B c d in the same way, then the order of the call is C,b,a, because we are here Class D (c,b), so the order of the call is C,b, if it is Class D (b,c), then the order of the call is B,cclass D (c,b):    Pass    # def Test_func ( Self):    #     print ("from d") D = d () D.test_func () # 1, if there is a Test_func method in Class D, then execute the method # from D#2 of Class D, if there is no test_ in class D FUCN This method, then the first execution of Class C in the Test_func method # from C#3, if Class C does not have test_func this method, then the method of Test_func in class B will be executed # from B#4, if there is no test_ in class B, C Func This method, then the method of Test_func in Class A is executed # from a

  

Multiple inheritance like Python

Related Article

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.