Call to __init__ of super class is missed
__init__ of super class is missed
If a parent class declare
__init__ method explicitly, even if that method is empty
then the sub class’s
__init__ method need to invoke parent’s
if not, a warning
Call to __init__ of super class is missed will be thrown by PyCharm.
Why? Please follow me, look at the first demo
If a sub class do not override
__init__ method, parent’s attributes will be inherited.
If a sub class want to declare its own attributes and inherit its parent’s attributes, do as follows:
Fine 3: Multiple Inheritance - solution 1
If a sub class inherits from multiple parent class, you should do like as follows.
If you do not explicitly invoke parent’s
__init__ for each parent class in Subclass’s
__init__, it will only inherit the first parent class‘s attributes.(The first parent class in the following code is Engine class.)
Fine 3: Multiple Inheritance - solution 2
Or like this:
(If you are not sure the parent class’s behavior, Solution 1 is very good.)
At the most time(Or always. Unless you know why you need not invoke init), you should invoke parent’s init in every subclass init method.