Below is a piece of code from the theory:
class Person:
def print_message(self):
print("Message from Person")
class Student(Person):
def print_message(self):
print("Message from Student")
super().print_message()
class Programmer(Person):
def print_message(self):
print("Message from Programmer")
super().print_message()
class StudentProgrammer(Student, Programmer):
def print_message(self):
super().print_message()
You've seen that if we call print_message() for StudentProgrammer class, we'll see the following:
jack = StudentProgrammer()
jack.print_message()
# Message from Student
# Message from Programmer
# Message from Person
Let's make sure that you understand this example. If you look at the classes again, both Student and Programmer refer to super() function. Then why doesn't the output look like the one below?
Message from Student
Message from Person
Message from Programmer
Message from Person