Python attribute lookup: The ICPO rule for finding methods

Python attribute lookup: The ICPO rule for finding methods

Python methods are stored on a class, not an instance.

Given x.m(), how does Python find it?

The ICPO rule:

– First, look for an attribute on the _i_nstance.
– Not there? Look on the _c_lass.
– Not here? Look on the _p_arent.
– Not there? Look on _o_bject, the final parent.