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.
The syntax of the class creation statement:
class (superclass):
#code follows
In the absence of any other superclasses that you specifically want to inherit from, the superclass
should always be object
, which is the root of all classes in Python.
object
is technically the root of "new-style" classes in Python. But the new-style classes today are as good as being the only style of classes.
But, if you don't explicitly use the word object
when creating classes, then as others mentioned, Python 3.x implicitly inherits from the object
superclass. But I guess explicit is always better than implicit (hell)
Reference