I have two classes, with the same parameter initialized by their __init__
method.
I would like to inherit both classes in class "X". But I will get: TypeError: B.__init__() missing 1 required positional argument: 'my_param'
Reproducible Example:
class A:
def __init__(self, my_param):
super().__init__()
self.my_param = my_param
class B:
def __init__(self, my_param):
super().__init__()
self.my_param = my_param * 2
class X(A, B):
def __init__(self, my_param):
super().__init__(my_param=my_param)
a = X(my_param=1)
print(a.my_param)
A and B are Mixins, they provide additional functionality for Child Classes. They can be used separetly or together. Lets's say class A provides searhc functionality for search by ID, where class B provides search by value.
Is there a way to set my_param for each of A and B or to set it without getting the error?