Jan-29-2024, 07:23 AM
hi
in the below code:
why the Age is 21 is displayed before the print result? and what is the None in the result of print? namely, is c.age=None?
thanks
in the below code:
'''
Python Multiple Inheritance and MRO
super usage() in python
from: https://www.geeksforgeeks.org/python-super/
'''
class A:
def age(self):
print("Age is 21")
class B:
def age(self):
print("Age is 23")
class C(A, B):
def age(self):
super(C, self).age()
c = C()
print(f"result of c.age()is {c.age()}")when the print line is inactive, nothing is displayed. when the print line is active, the output will be(I use Idle):Output:Age is 21
result of c.age()is NoneI expect the output will be: result of c.age is Age is 21why the Age is 21 is displayed before the print result? and what is the None in the result of print? namely, is c.age=None?
thanks
