[Tutor] Clarity about MRO (method resolution order )

Alan Gauld alan.gauld at yahoo.co.uk
Sat Nov 27 05:46:39 EST 2021


On 27/11/2021 01:30, Manprit Singh wrote:

> ABC12.mro()  will result in
> 
> [__main__.ABC12, __main__.ABCD, __main__.ABCDE, __main__.ABC, object]
> 
> According to this MRO, show() will be searched in the classes in the order
> given in the output of ABC12.mro(). show() was first searched in ABC12 class,
> it was not there , and hence it was searched in ABCD class, it was present
> and hence executed.
> 
> Am I right with this explanation ?

Yes, absolutely.


-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list