I dont understand why the childs method set_state()
is called here, when i call it from the __init__()
method of the base class:
class base():
def __init__(self, x):
self.set_state(x)
def set_state(self, x):
self.x = x
print("base")
class child(base):
def __init__(self, x, y):
super().__init__(x)
self.set_state(y)
def set_state(self, y):
self.y = y
print("child")
test = child(1, 2)
Output is:
child
child