Hi Folks, Could anyone help me with "Method Resolution Order" incase of Multilevel inheritance in python. | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
0

Hi Folks, Could anyone help me with "Method Resolution Order" incase of Multilevel inheritance in python.

Do share some sample codes as well.

10th May 2018, 5:08 AM
Karan Chaudhary
Karan Chaudhary - avatar
1 ответ
+ 2
Method resolution works from the bottom of the inheritance tree upward. class Base: def foo(self): return 'Base' class Child(Base): def foo(self): return 'Child' class Grandchild(Child): pass g = Grandchild() print(g.foo()) This prints 'Child'
9th Jun 2018, 3:14 AM
1_coder