If you use super() , you must use it consistently to ensure that methods of all classes are called. The Base1 and Base2 classes must also call super(...).__init__() in their __init__() methods. This ensures that all classes in order of method resolution are ultimately called.
This is a bit complicated when not all __init__() methods have an empty argument list. At some point, super() will call object.__init__() , and this never takes any arguments. The trouble is that you donβt know what classes this can happen in advance. You can fix this by creating a subclass of object that takes any number of arguments in __init__() and follows from this. This class should not call object.__init__() because this method actually does nothing (or, if you are paranoid, which can change, you can call object.__init__() without using super() ).
In the general case, super() requires special attention when processing arguments, because you cannot know which class will be next in order of method resolution, since users of your code can create new classes using base classes in combinations that you do not expect. Therefore, you will need to do some work to make sure that the method signatures in all your classes are compatible.
For more information, see Raymond Hettinger seminal Python Super () reviewed by super .
source share