Python Method Resolution Order / MRO, Super, and Diamond Inheritance Problem

Subscribers:
50,600
Published on ● Video Link: https://www.youtube.com/watch?v=HAe6kKOkVJg



Duration: 0:00
192 views
9


Method Resolution Order / MRO in Python. Python uses the method resolution order to resolve the diamond inheritance problem. The diamond Inheritance problem occurs with multiple inheritance, where parent classes can have different implementations of a method. When a child class then tries to call the method, we get a conflict. Which parent method should we use? With MRO, python selects the left most parent and if the method can't be called with said parent, it would continue to the next parent to the right. If none of the parents method can be used, it will go up another level. Therefore, MRO is from left to right, bottom to top. While MRO resolves the diamond inheritance problem, it creates another problem with the super function.

Source Code:
https://github.com/ImKennyYip/python-oop

Python Object Oriented Programming Playlist:
   • Python Object Oriented Programming  

Python Data Structures and Algorithms Playlist:
   • Python Data Structures and Algorithms  

Python Game Programming Projects Playlist:
   • Python Game Programming Tutorial  

Subscribe for more coding tutorials 😄 !