How does "delegation" work as per the FAQ?

Terry Reedy tjreedy at
Fri Dec 26 06:25:23 CET 2003

"Rene Pijlman" < at> wrote in
message news:10gmuvc8pqt5opt7o4l6qp1683kf7sl2f3 at
> Ville Vainio:
> >Rene Pijlman:
> >> __getattr__: "Called when an attribute lookup has not found the
> >> in the usual places". There is no mention of method calls.
> >
> >A method is an attribute.
> I see. But how are the arguments of a method call passed on, when
> delegation is implemented this way?

The delegation is done before the call, in order to find the (delegated-to
method) object on which to make the call.  The alternative is to write a
wrapper method for each method delegated to and explicitly pass the args on
with *args and ** args.  But doing the delegation before the call in the
method lookup make this not necessary and is much easier.

Terry J. Reedy

More information about the Python-list mailing list