addressalign-toparrow-leftarrow-rightbackbellblockcalendarcameraccwcheckchevron-downchevron-leftchevron-rightchevron-small-downchevron-small-leftchevron-small-rightchevron-small-upchevron-upcircle-with-checkcircle-with-crosscircle-with-pluscontroller-playcrossdots-three-verticaleditemptyheartexporteye-with-lineeyefacebookfolderfullheartglobegmailgooglegroupshelp-with-circleimageimagesinstagramFill 1light-bulblinklocation-pinm-swarmSearchmailmessagesminusmoremuplabelShape 3 + Rectangle 1ShapeoutlookpersonJoin Group on CardStartprice-ribbonprintShapeShapeShapeShapeImported LayersImported LayersImported Layersshieldstartickettrashtriangle-downtriangle-uptwitteruserwarningyahoo

Multiple Inheritance and Method Resolution Order

When class X has several base classes, different combinations of these base classes may define the same method Y.  When you ask for method Y on an X object, how does Python pick the right one?  For that matter, what does "the right one" even mean?

The method resolution order for class X is the order of all of the classes that make up X (including X itself) that Python will use for method lookups.  When method Y is asked for, Python examines each class in this order until it finds one that defines a method Y.  This is the method that is selected for X.

Mike will explain how Python determines this method resolution order.  This is particularly important when you are using multiple inheritance. This is also what determines how the super function works.  For example, if a method in class X does a super call, will Python always select the same method?  The answer may surprise you!

Join or login to comment.

2 went

Our Sponsors

People in this
Meetup are also in:

Sign up

Meetup members, Log in

By clicking "Sign up" or "Sign up using Facebook", you confirm that you accept our Terms of Service & Privacy Policy