On the Topic Of MRO Theory

Hi Pythonistas,

I have a question regarding the (Method Resolution Order) MRO concept. The book states the following:

The new-style MRO allows lower superclasses to overload attributes of higher superclasses, regardless of the sort of multiple inheritance trees they are mixed into.

Can someone please elaborate.

See here, in particular the paragraph regarding the merge

take the head of the first list, i.e L[B1][0]; if this head is not in the tail of any of the other lists, then add it to the linearization of C and remove it from the lists in the merge, otherwise look at the head of the next list and take it, if it is a good head. Then repeat the operation until all the class are removed or it is impossible to find good heads. In this case, it is impossible to construct the merge, Python 2.3 will refuse to create the class C and will raise an exception.*

Within this paragraph the condition

if this head is not in the tail of any of the other lists …

for when a “head” of a list gets merged, seems to be what causes the claim in the quote from your book.

Hi,

thank for responding to my query. I went to the link that you provided. The title states that it applies to Python 2.3. Is this still relevant to v3.X?

You could skip to the section " The C3 Method Resolution Order". I believe it is still the recipe used in Python3.

1 Like

Ok, thank you for providing this lead.

Much appreciated!