I have a code here:
class Prey:
def __init__(self):
super().__init__()
print("Prey's init")
class Predator:
def __init__(self):
super().__init__()
print("Predator's init")
class Rabbit(Prey):
def __init__(self):
super().__init__()
print("Rabbit's init")
class Fish(Prey, Predator):
def __init__(self):
super().__init__()
print("Fish's init")
class Hawk(Predator):
def __init__(self):
super().__init__()
print("Hawk's init")
class Creature(Rabbit, Fish, Hawk):
def __init__(self):
super().__init__()
print("Creature's init")
c = Creature()
The Relationship of the above code is here:
Prey Predator
/ \ / \
Rabbit Fish Hawk
\ | /
Creature
And the output of the above code is here:
Predator's init
Hawk's init
Prey's init
Fish's init
Rabbit's init
Creature's init
I need to understand how Method resolution Order works in python and why this specific output? (If someone have some better tutorial you can refer, please feel free to paste the link.) I have some other code which I can't paste it here, so I'm pasting here with a silly example.