0
Just to make sure if I understood the Lesson 74.1 correctly
Is super function like if there are the same methods in superclass and subclass, super function calls superclass' method?
1 Réponse
+ 1
If you have a subclass, the __init__ method should include a call to the super classes __init__ method.
class A:
def __init__(self):
self.val = 5
class B(A):
def __init__(self):
super().__init__()
Now if you create an instance of class B, it will have the val attribute that has the value 5. This is only set because of the call to the super classes __init__ method INSIDE of the subclass __init__ method.