Types and classes in Python

后端 未结 3 575
离开以前
离开以前 2021-02-05 08:36

I\'m a bit confused about types and classes in Python. For e.g. the following REPL conversation confuses me:

>>> class A: pass
... 
>>> a = A()         


        
3条回答
  •  你的背包
    2021-02-05 09:17

    In Python 3.0, user-defined class objects are instances of the object named type, which is itself a class. • In Python 2.6, new-style classes inherit from object, which is a subclass of type; • classic classes are instances of type and are not created from a class.

提交回复
热议问题