[Python-Dev] Missing operator.call

"Martin v. Löwis" martin at v.loewis.de
Wed Feb 4 20:48:03 CET 2009


> If there is interest in this and no reason why it shouldn't be done, I
> can write up an issue in the tracker and provide a patch.

I think there is a tricky design choice to make wrt. argument passing.
IIUC, you don't care much about arguments, so you could probably live
with

def call(o):
    return o()

Somebody proposed that you pass arguments once, and get an
"arguments bound" object, i.e.

def call(*args, **kwds):
    def func(o):
        return o(*args, **kwds)
    return func

Finally, it seems that Guido is advocating an API where arguments get
passed along with the callable, i.e.

def call(o, *args, **kwds):
    return o(*args, **kwds)

which would make call a synonym for apply (and would also provide for
the first definition as a special case). However, with that API, it
isn't so easy anymore to pass the same arguments to all callables
(unless it is no arguments that you want to pass).

Regards,
Martin


More information about the Python-Dev mailing list