Hello all,
Base is parent and Child inherited .
Should argument(s) in the __init__of the child class be same as what we have in the __init__ 's parent?
I get an error.
Base is parent and Child inherited .
Should argument(s) in the __init__of the child class be same as what we have in the __init__ 's parent?
I get an error.
class Base(): def __init__(self,a,b): self.a = a self.b = b print("From Parent Class")
class Child(Base): def __init__(self): super().__init__(self,a,b) # or Base.__init__(self,a,b) print("From Child Class")
childobject=Child()After trying to make an object from Child Class :
Error:NameError Traceback (most recent call last)
<ipython-input-80-3762dc95e937> in <module>
----> 1 childobject=Child()
<ipython-input-79-b57528e5fe56> in __init__(self)
2
3 def __init__(self):
----> 4 super().__init__(self,a,b)
5 print("From Child Class")
NameError: name 'a' is not defined