I have a superclass and a subclass. The superclass contains a constructor holding some attributes, and the subclass too, should have a constructor which initializes some attributes. The problem is, however, that when i make an __init__ method in my subclass, it overrides the constructor of the superclass.
How can this be solved so the subclass’s constructor doesn’t override the superclass’s constructor method?
Thank you very much!
Make the subclass call the superclass
__init__method. You can do this either explicitly, or using thesuperfunction. For simple cases like single inheritance, both methods are equivalent.