The difference between super (). __init__ and class name in Python. __init__

Source: Internet
Author: User
  1. super (). __init__ relative to the class name. __init__, the usage is basically no difference on single inheritance
  2. However, there is a difference in multiple inheritance , the super method guarantees that the methods of each parent class will only be executed once, and the method using the class name will cause the method to be executed multiple times
  3. multiple inheritance , using the Super method, the parent class of the arguments, should be due to the super algorithm in Python cause, must pass all parameters, otherwise it will error
  4. single inheritance , using Super method, you can not pass all, can only pass the parameters required by the parent class method, otherwise it will error
  5. multiple inheritance , relative to the use of the class name. __init__ method, to write each parent class all over, and use the Super method, just write a sentence to execute all the parent class method, this is why more inheritance requires all the argument of a reason

The difference between super (). __init__ and class name in Python. __init__

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.