0
Hello, I’m making inheritance in python and I’m encountering the following error:
Typeerror:
__init__()
takes Exactly 2 positional Arguments (4 Given)
class A():
def __init__(self,a,b):
self.a = a
self.b = b
class B(A):
def __init__(self,c):
self.c = c
super().__init__(self)
if __name__ == '__main__':
a =10
b = 5
c = 8
teste = B(a,b,c)
In class B
i would like to use the class builder A
and add one more parameter in the class constructor B
.
B(a,b,c)
, you’re calling the__init__
ofB
with three arguments when the function signature expects only one– Miguel
As I would for instantiating class B and using the constructor parameters a,b of class A and also the new parameter c of class B?
– Core
Are you working on legacy code or are you just studying? If you are studying I advise you to study python3, otherwise good luck. : D
– fernandosavio