How will be use super in case of multiple inheritance?
Hi @Avnish,
This Waleed from Educative. I am glad you reached out to us.
This is a very interesting question. The use of super()
in multiple inheritance will depend on the order of arguments in the child class definition.
class C1():
def hello(self):
print("1")
class C2():
def hello(self):
print("2")
class C3(C1, C2):
def print_details(self):
super().hello()
obj = C3()
obj.print_details()
This program will print 1
, since order of arguments is C1
and C2
. If you switch the order of the arguments of C3
class definition to class C3(C2, C1)
, this program will print 2
.
We hope Educative has inspired to further your learning.
Best Regards,
Waleed | Developer Advocate
educative.io