Demo of MRO resolution with multiple inheritance

This commit is contained in:
Donald Calloway 2025-09-24 09:22:20 -07:00
parent 1da4f731a5
commit bac5abb664

20
mro_resolution_example.py Normal file
View File

@ -0,0 +1,20 @@
# Example to demonstrate Method Resolution Order (MRO) in Python
class A:
def greet(self):
print("Hello from A")
class B(A):
def greet(self):
print("Hello from B")
class C(A):
def greet(self):
print("Hello from C")
class D(C, B):
pass
d = D()
d.greet() # Hello from C (based on MRO)