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

People in this
Meetup are also in:

Create a Meetup Group and meet new people

Get started Learn more
Bill

I started the group because there wasn't any other type of group like this. I've met some great folks in the group who have become close friends and have also met some amazing business owners.

Bill, started New York City Gay Craft Beer Lovers

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