class FakeBase(object):
def __init__(self, *args):
pass
class Parent(FakeBase):
def __init__(self, x=1, *args):
super().__init__(x, *args)
self.var1 = x
class Parent2(FakeBase):
def __init__(self, x=3, y=4, *args):
super().__init__(x, y, *args)
self.var2 = x
self.var3 = y
class Child(Parent, Parent2):
def __init__(self, z, *args):
super().__init__(*args)
self.var4 = z
childObject = Child("var4", "var3", "var1", "var2")
print(childObject.var1)
print(childObject.var2)
print(childObject.var3)
print(childObject.var4)
The result is:
var3
var3
var1
var4
I just started dealing with Python multiple inheritance.
Here, I am only able to call the super().__init__(x)
with one parameter. And it will only call the parent's __init__()
. I want to initial var2
and var3
also. How to do that?
Getting hits from your answers, I tried to modified my code.
But, still not getting the way to initial all four parameters. And none of your answers did neither.
Thanks and still waiting for the answer.