Codie CodeMonkey Codie CodeMonkey - 1 year ago 76
Python Question

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

The Python documentation says that the

method of each class is responsible for initializing its super class. But for new-style classes, the ultimate base class is
. Doing
shows that
itself has an
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.

Answer Source

You don't need to initialize object; its __init__ is a no-op. It's still good practice, though, as you might want to introduce an intermediate class in the hierarchy later on.