Python class inherits object

后端 未结 6 1047
慢半拍i
慢半拍i 2020-11-21 15:54

Is there any reason for a class declaration to inherit from object?

I just found some code that does this and I can\'t find a good reason why.



        
6条回答
  •  野性不改
    2020-11-21 16:26

    Yes, it's historical. Without it, it creates an old-style class.

    If you use type() on an old-style object, you just get "instance". On a new-style object you get its class.

提交回复
热议问题