When I call a method that was overrided from my constructor, I am getting an error and it says that it is missing an argument (due to the subclass requiring a second argument). However, I called the method in the super(), so why doesn't it call the super class version of that method?
This is best illustrated with a short example:
class A:
def __init__(self):
self.do()
def do(self):
print("A")
class B(A):
def __init__(self):
super().__init__()
self.do("B")
def do(self, arg2):
super().do()
print(arg2)
b = B()
Here is the error I get:
Traceback (most recent call last):
File "D:/Python/Advanced/randomStuff/supersub.py", line 19, in <module>
b = B()
File "D:/Python/Advanced/randomStuff/supersub.py", line 11, in __init__
super().__init__()
File "D:/Python/Advanced/randomStuff/supersub.py", line 3, in __init__
self.do()
TypeError: do() missing 1 required positional argument: 'arg2'
It seems to be calling the do() method in class B, but I want to call the do() method in Class A. Ideally, the code should print:
A
A
B
What am I doing wrong?