016-python Increase 02-polymorphic attribute Mrocontext

Source: Internet
Author: User

MRO: Role: Determine how super () in multiple inheritance calls method order?? Super () Effect: super () does not call the parent class method, but instead calls the method of the other class according to the order of the MROclassP (obj);classS1 (P);classS2 (P);classS3 (P);classGS1 (S1,S2,S3)Print(Gs1.mro ()) Polymorphism: The polymorphism in Python is not rigorous. Reason: Python does not have type restriction classes and instances: Class objects can access instance methods, class methods, static method instance objects can access instance methods, class methods, static method class objects can access class properties, cannot access instance property instance objects can Sufficient access to class properties, instance Properties#This invocation property is in the order of the method reference:The instance properties initialized with Init are followed by assignments based on the order in which you initialize them in the file, resulting in the last value of context (context Manager): definition: Implemented__init__()、__enter__()、__exit__The instance of the class of the () method is the context manager

016-python Increase 02-polymorphic attribute Mrocontext

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.