I have a class D
, this class inherits the classes B
and C
, which both inherit A
, but when I created an instance of class D
this error occurred:
johni@johni-pc:~/Draft$ python3.4 main.py
Traceback (most recent call last):
File "main.py", line 35, in <module>
d = D()
File "main.py", line 31, in __init__
super().__init__()
File "main.py", line 19, in __init__
super().__init__("pg")
TypeError: __init__() takes 1 positional argument but 2 were given
I don't understand this.
The classes B
and C
are initializing the parameter driver
in class A
. My file main.py
:
class A:
def __init__(self, driver):
self.driver = driver
@property
def driver(self):
return self.__driver
@driver.setter
def driver(self, valor):
self.__driver = valor
def run_driver(self):
print("I am executing with %s" % self.driver)
class B(A):
def __init__(self):
super().__init__("pg")
class C(A):
def __init__(self):
super().__init__("conn_pg")
class D(B, C):
def __init__(self):
super().__init__()
d = D()
print(d.run_driver())
Why did this error occur?