I have one parent class that’s constructor takes some arguments to initialize and want the same constructor in the child class and add more parameters to it
# Parent class
class Parent:
def __init__(
self,
name: str = None,
state: str = False,
dry_run: bool = False
):
self.name = name
self.state = state
self.dry_run = dry_run
# Child class
class Child(Parent):
def __init__(self, name):
self.name = name
super().__init__()
I have tried to add all the parameters manually using super.init(*args, **kwargs).
>Solution :
You have to add *args and **kwargs inside def int and super init like this
class Child(Parent):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
Then your inheritance should work
child_instance = Child(name="Child Name", state=True, dry_run=True)