Today, I read the official doc of super.
In which it mentioned multiple inheritance will be decided by the __mro__
attribute of a class.
So I did a bit
From chapt 32 of learning python:
each super call selects the method from a next class following it in the MRO ordering of the class of the self subject of a method call.
so for super(cls, instance)
(isinstance(instance, cls)
must be True
), the method is selected from the next class in instance.__class__.__mro__
starting from instance.__class__
.
for super(cls0, cls1)
(issubclass(cls1, cls0)
must be True
), the method is selected from next class in cls1.__mro__
starting from cls0
in both cases, if the method is not implemented by the next class in the MRO chain, the search will skip ahead until it finds a class with the method defined.