Given the following classes A, B, and C:
class A:
def __init__(self, a, aa, aaa):
self.a = a
self.aa = aa
self.aaa = aaa
class B:
def __init__(self, b, bb, bbb):
self.b = b
self.bb = bb
self.bbb = bbb
class C(A, B):
def __init__(self, **kwargs):
super(C, self).__init__(**kwargs)
I want to avoid having to repeat all the superclasses parameters a, aa, aaa, b, bb, bbb, in C definition:
class C(A, B):
def __init__(self, a, aa, aaa, b, bb, bbb):
super(C, self).__init__(**kwargs)
and somehow pass A and B kwargs to be resolved in super().__init__ call but this is not possible using the way I described and will result in an error:
>>> c = C(a=1, aa=2, aaa=3, b=4, bb=5, bbb=6)
TypeError: A.__init__() got an unexpected keyword argument 'b'
The correct way of doing so is calling A.__init__(self, **a_kwargs) and B.__init__(self, **b_kwargs) but as I said this creates redundant parameters I'm trying to avoid. Is there a better way to achieve the same thing?