This is my current setup:
class Base():
def __init__(self):
pass
# ...other methods
class A(Base):
def __init__(self, dst, fname, alg, src=None):
super().__init__()
# I then use these instance variables throughout instance methods.
self.src = [] if src is None else src
self.dst = dst
self.fname = fname
self.alg = alg
# ...other methods
class B(Base):
def __init__(self, fname):
super().__init__()
# I then use these instance variables throughout instance methods.
self.fname = fname
# ...other methods
class C(A, B):
"""Here is my problem.
When I try to inherit A and B this way,
I keep getting those "missing required positional args..." errors
"""
def __init__(self, dst, src=None):
super().__init__()
# I then use these instance variables throughout instance methods.
self.fname = fname
# ...other methods
Here is what I am trying to do right now:
class Base():
def __init__(self, *args, **kwargs):
pass
class A(Base):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
class B(Base):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
class C(A, B):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
My main question:
What is the "best" (standard, most preferred, efficient, readable etc.) way to handle such situations?
P.S.
- I read the following article, Python’s super() considered super!, but I could not derive the best answer for myself after reading it.
- Also, I referenced this SO question but the accepted answer does not have different number of params like I do...
- By the way, I am willing to hear that my design (class hierarchy) is bad overall. Technically, I could relocate methods that I am trying to inherit from A and B in C to the Base class...I hope (did not try yet)...