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

前端 未结 6 1992
太阳男子
太阳男子 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条回答
  •  萌比男神i
    2020-11-30 06:02

    Python 2.2 introduced "new style classes" which had a number of additional features relative to the old style classes which did not subclass object. Subclasses object was the chosen way to indicate that your class should be a new style class, not an old style one.

提交回复
热议问题