In python, why is recommended to inherit any class we make from the class object , why not directly make it as the base class??
An important thing I noticed is 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 by inheriting my class from the class object?
In python, why is recommended to inherit any class we make from the class
Share
In Python2, you must inherit from object in order 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 backwards compatibility.In Python3, all classes are new-style classes, so inheriting from
objectis no longer necessary.