I found out this wonderful entry, which has a detailed explanation on finding attributes of an object / class.
To search for attributes of an object:
The alleged Class is a class, and instance is an instance of Class , evaluating instance.foobar approximately equal this:
- Call the type slot for
Class.__getattribute__ ( tp_getattro ). The following is executed by default:- Does
Class.__dict__ a foobar element which is a data descriptor?- If so, return the result of
Class.__dict__['foobar'].__get__(instance, Class) .
- Is there an
'foobar' element in instance.__dict__ ?- If so, return
instance.__dict__['foobar'] .
- Does
Class.__dict__ an foobar element that is not a data descriptor [9]?- If so, return the result of
Class.__dict__['foobar'].__get__(instance, klass) . [6]
- If the attribute is still not found and there is
Class.__getattr__ , call Class.__getattr__('foobar') .
There is an illustrated image for this:

Please check out the source blog if interested, which gives a great explanation for the python class, attribute lookups and metaclass.
source share