[Python-Dev] Missing operator.call

Hrvoje Niksic hrvoje.niksic at avl.com
Wed Feb 4 14:02:17 CET 2009


Is there a reason why the operator module doesn't have an operator.call 
function?  It would seem logical to be able to write:

map(operator.call, lst)

which calls each object in lst, just like map(operator.neg, lst) negates 
every object.  Of course, operator.call is equivalent to lambda x: x(), 
but such an equivalence exists for all functions in the operator module.

__call__ should also be provided for symmetry with other operators that 
correspond to special-name methods.

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.


More information about the Python-Dev mailing list