Python Class and Class (object) Usage differences

Source: Internet
Author: User

#-*-coding:utf-8-*-#Classic class or Old test classclassA:Passa=A ()#New ClassclassB (object):Passb=B ()#Python2 not supported#print (a.__class__)Print(A.__class__)Print(Type (A))Print(Type (a))#Python2#__main__. A#<type ' classobj ' >#<type ' instance ' >#Python3#<class ' type ' >#<class ' __main__. A ' >#<class ' type ' >#<class ' __main__. A ' >PrintB.__class__)Print(b.__class__)Print(Type (B))Print(type (b))#Python2#<type ' type ' >#<class ' __main__. B ' >#<type ' type ' >#<class ' __main__. B ' >#Python3#<class ' type ' >#<class ' __main__. B ' >#<class ' type ' >#<class ' __main__. B ' >#the implementation of the old class is not good enough, the class is a class, the instance is an instance, the class type is classobj, the type of the instance is instance, the relationship between the two is only __class__,#this is different from the built-in object, where the type of the int object is int, and the int () returns an object of type int, and the built-in object and the custom object are different, which brings great difficulty to the unified implementation of the code. ##New Class##1. The types of all classes are type#2. The results of all class invocations are constructed, returning instances of this class#3. All classes are subclasses of object#4. The new class can not only invoke the parent class's method with the old class, but also use the Super method. 

from:https://my.oschina.net/shyl/blog/692930

Python Class and Class (object) Usage differences

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.