class A:
def __init__(self, x1, x2, x3, x4):
pass
...
class B(A):
def __init__(self, x1, x2, x3, x4, y1, y2):
super().__init__(x1, x2, x3, x4) # How to replace this without repeating the argument names?
...
I prefer not to use **kwargs or dicts, as it hides the actual signature.
One solution could be something like:
from inspect import signature
class B(A):
def __init__(self, x1, x2, x3, x4, y1, y2):
sig = signature(super().__init__)
params = {k: v for k, v in locals().items() if k in sig.parameters}
super().__init__(**params)
...
But this is cumbersome and has its own problems. Is there anything more elegant that could be done?
Edit: The motivation to this question is the DRY principle.