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

前端 未结 6 2020
太阳男子
太阳男子 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:53

    Short answer: subclassing object effectively makes it a new-style class (note that this is unnecessary since automatic in Python 3.x)

    For the difference between new style classes and old style classes: see this stackoverflow question. For the complete story: see this nice writeup on Python Types and Objects.

提交回复
热议问题