I am doing my college assignment and I got stuck here, I am not understanding the this function in multiple inheritances.
# python 3 syntax
# multiple inheritance example
class parent1: # first parent class
def func1:
print(“Hello Parent1”)
class parent2: # second parent class
def func2:
print(“Hello Parent2”)
class parent3: # third parent class
def func2: # the function name is same as parent2
print(“Hello Parent3”)
class child(parent1, parent2, parent3): # child class
def func3: # we include the parent classes
print(“Hello Child”) # as an argument comma separated
# Driver Code
test = child() # object created
test.func1() # parent1 method called via child
test.func2() # parent2 method called via child instead of parent3
test.func3() # child method called
# to find the order of classes visited by the child class, we use __mro__ on the child class
print(child.__mro__)
What I am not understanding is the code, can anyone explain to me how this code will work?
There are many articles on python that I am reading to complete my assignment and I am totally confused now.
Thanks for your help!