git.net

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Understanding the MRO with multiple inheritance


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