[Python-Dev] Missing operator.call

Hrvoje Niksic hrvoje.niksic at avl.com
Thu Feb 5 11:11:40 CET 2009


Guido van Rossum wrote:
>> 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).
> 
> My version is in line with the other operators in the operator module.
> The version that binds the arguments and returns a callable is already
> available as functools.partial.

And it works well in the case I encountered.  In fact, it works even 
better because it allows things like map(call, l1, l2) to apply each 
element of l2 to the corresponding function in l1.

If there's no opposition to this, I'll post a patch to the tracker.


More information about the Python-Dev mailing list