class Base:
def __init__(self, x, y, *args, **kwargs):
pass
class A(Base):
def __init__(self, x, y, z, *args, **kwargs):
super().__init__(x, y, *args, **kwargs)
class B(Base):
def __init__(self, x, y, t, *args, **kwargs):
super().__init__(x, y, *args, **kwargs)
class C(A, B):
def __init__(self, x, y, z, t, *args, **kwargs):
super().__init__(x, y, z, *args, **kwargs)
C(1, 2, 3, 4)
Traceback (most recent call last):
File "test.py", line 25, in <module>
C(1, 2, 3, 4)
File "test.py", line 22, in __init__
A.__init__(self, x, y, z, *args, **kwargs)
File "test.py", line 10, in __init__
super().__init__(x, y, *args, **kwargs)
TypeError: __init__() missing 1 required positional argument: 't'
I first try to add '*args' and '**kwargs', but it didn't work. I wonder why this happen? How to fix? Could someone explain this for me? Thank you!