Typeerror:must be type of super in Python, not classobj cause and resolution

Source: Internet
Author: User

Execute the code, there is an error, Typeerror:must is type, not classobj


Class A ():
def __init__ (self):
Print ("Enter A")
Print ("Leave A")

Class B (A):
def __init__ (self):
Print ("Enter B")
Super (B, self). __init__ ()
Print ("Leave B")

Class C (A):
def __init__ (self):
Print ("Enter C")
Super (C, self). __init__ ()
Print ("Leave C")

Class D (A):
def __init__ (self):
Print ("Enter D")
Super (D, self). __init__ ()
Print ("Leave D")

Class E (B, C, D):
def __init__ (self):
Print ("Enter E")
Super (E, self). __init__ ()
Print ("Leave E")

E ()

Output error:

Traceback (most recent):
File "f:/test5.py", line A, in <module>
E ()
File "f:/test5.py", line +, in __init__
Super (E, self). __init__ ()
Typeerror:must is type, not classobj

Baidu later found that the Python super can only be applied to the new class, but not to the classic class

See: http://blog.csdn.net/andos/article/details/8973368


Normal after using the new class (that is, a inherits from object).


This article is from the "Farley" blog, make sure to keep this source http://10250691.blog.51cto.com/10240691/1851741

Typeerror:must be type of super in Python, not classobj cause and resolution

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.