Why is it good nature to inherit any class that we make from an object class?

In python, why is it recommended to inherit any class we make from a class object, why not make it directly as a base class? I noticed that the declaration __slots__does not work if I make my class as a base class (instead, as a subclass of the class object). What other advantages / disadvantages do I have when inheriting my class from class object?

+3
source share
2 answers

In Python2, you must inherit an object to create a "new style" class . Things like descriptors, superand __slots__, do not work correctly with "old-style" classes, but old-style classes remained for backward compatibility.

In Python3, all classes are new-style classes, so inheritance is objectno longer required.

+6
source

when you inherit an object created by a new style class, without it you have an old style class: http://www.python.org/doc/newstyle/ for more

0
source

Source: https://habr.com/ru/post/1784270/


All Articles