Call super().__init__() in classes derived from `object`?

Viewed 1779

The Python documentation says that the __init__ method of each class is responsible for initializing its super class. But for new-style classes, the ultimate base class is object. Doing dir(object) shows that object itself has an __init__ method and could potentially be initialized. Is there any reason to do that?

I'm inclined to do it for consistency and (slightly) easier refactoring of the class heirarchy, but I wonder if it's strictly necessary or is considered best practice.

4 Answers

Yes, and there is a reason why you should do it.

If you ever need to use multi inheritance, python's C3 method resolution order (MRO) will not call all your __init__() base classes.

Related