Subclass __init__ Overrides Superclass's
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
Solution 1:
Make the subclass call the superclass __init__
method. You can do this either explicitly, or using the super
function. For simple cases like single inheritance, both methods are equivalent.
class Subclass(Superclass):
def __init__(self):
Superclass.__init__(self)
class Subclass(Superclass):
def __init__(self):
super(Subclass, self).__init__()
Post a Comment for "Subclass __init__ Overrides Superclass's"