If the subclass defines its own _ init _ constructor, when the Instance Object of the subclass is created, the subclass will only execute its own _ init _ method function, if the subclass does not define its own constructor, it will find the constructor of the parent class along the search tree to execute the constructor in the parent class.
For example, if a subclass defines its own constructor, if the constructor of the subclass does not actively call the constructor of the parent class, the instance variable of the parent class does not appear when the subclass instance object is just created.
Class aa: def _ init _ (self): self. x = 10 self. y = 12 def hello (self, x): return x + 1 class bb (aa): def _ init _ (self): aa. _ init _ (self) # If this row is canceled, print B below. x and B. y will report an error, not defined # calling the constructor self of the parent class through the class name. z = 14 a = aa () print. x,. yb = bb () print B. x, B. y