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

  • TekSystems

    Provides free pizza and sodas at the meetings.

  • Novetta

    Donation of $500 to promote Python in the community.

People in this
Meetup are also in:

Create your own Meetup Group

Get started Learn more

We just grab a coffee and speak French. Some people have been coming every week for months... it creates a kind of warmth to the group.

Rafaël, started French Conversation Group

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