Understanding the MRO with multiple inheritance

Chris Angelico rosuav at gmail.com
Fri Mar 29 21:32:11 EDT 2019


On Fri, Mar 29, 2019 at 11:54 PM Arup Rakshit <ar at zeit.io> wrote:
>
> Now when I call the add method on the SortedIntList class’s instance, I was expecting super.add() call inside the IntList class add method will dispatch it to the base class SimpleList. But in reality it doesn’t, it rather forwards it to the SortedList add method. How MRO guides here can anyone explain please?
>

When you call super, you're saying "go to the next in the MRO". You
can examine the MRO by looking at SortedIntList.__mro__ - that should
show you the exact order that methods will be called.

ChrisA



More information about the Python-list mailing list