Building CPython

Terry Reedy tjreedy at udel.edu
Fri May 15 19:54:31 EDT 2015


On 5/15/2015 5:54 PM, BartC wrote:

> What /is/ a method lookup? Is it when you have this:
>
>   A.B()

This is parsed as (A.B)()

> and need to find whether the expression A (or its class or type) has a
> name B associated with it?

Yes.  Dotted names imply an attribute lookup.

> (And it then needs to check whether B is something that can be called.)

The object resulting from the attribute lookup, A.B (not B exactly), is 
called in a separate operation (with a separate bytecode). It depends on 
the object having a .__call__ method.  The .__call__ method is 
*executed* (rather than *called*, which would lead to infinite regress).

-- 
Terry Jan Reedy




More information about the Python-list mailing list