0
If a class that inherits from another class automatically also inherits its constructor then why bother using super().__init__?
Whats the purpose? Example: class A: def __init__(self, y, x): self.y = y self.x = x class B(A): def __init__(self,x): super().__init__(x, x) Why not just: class B(A): pass
1 Réponse
+ 3
For one, you pass values in the super constructor. So it'll need those values regardless now. Plus if you dont do the super's init method, you won't get the x and y attributes cause they will never be set. It doesn't just automatically happen, you still have to do it.