What is the purpose of subclassing the class “object” in Python?

前端 未结 6 2016
太阳男子
太阳男子 2020-11-30 05:15

All the Python built-ins are subclasses of object and I come across many user-defined classes which are too. Why? What is the purpose of the class object<

6条回答
  •  悲&欢浪女
    2020-11-30 05:49

    It has to do with the "new-style" of classes. You can read more about it here: http://docs.python.org/tutorial/classes.html#multiple-inheritance and also here: http://docs.python.org/reference/datamodel.html#new-style-and-classic-classes

    Using new-style classes will allow you to use "Python's newer, versatile features like __slots__, descriptors, properties, and __getattribute__()."

提交回复
热议问题