I have this class of classes
class C: Def __init __ (Self): PRINT ('C') Class A: Def __init __ (Self): PRINT ('A') Class B (C): Def __init __ (Self): C .__ INIT __ (SELF) PRINT ('B') Class D (B, A): x = 'x'
Create an object:
I get to my great surprise:
I thought all my life, which should be so until I came across:
Have you really need a second-parent class to initialize and call it constructor? Why so?
Answer 1, Authority 100%
When the class object is created, the interpreter tries to find the
__ init __ method in accordance with the order of resolution of the methods (MRO) moving along the inheritance hierarchy until the first ancestor finds, With which this method is defined, and further to search will not be.