I would like to know if I can use the parent constructor for passing parameters which will be needed for every subclass. So for instance:
Class A():
def __init__(a,b):
...do some stuff...
Class B(A):
def __init__(c,d):
...do some stuff needing a and b...
Class C(A):
def __init__(e,f,g):
...do some stuff needing a and b...
Basically there are some parameters each of my subclasses is going to want and some others which are specific. I don’t want to have to add a,b to the definition of every subclass of A. Is there some way I can do this in python?
What I’d like to see is the ability to call:
b=B(a=1,b=2,c=3,d=4)
without having to include a and b in the subclass definition.
Many thanks!
1 Answer