Past Meetup

Multiple Inheritance and Method Resolution Order

This Meetup is past

2 people went


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!

See all Meetups from Tampa Bay Python