classification
Title: operator.call/operator.__call__
Type: Stage:
Components: Library (Lib) Versions: Python 3.11
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Antony.Lee, hrik2001
Priority: normal Keywords:

Created on 2021-05-03 14:24 by Antony.Lee, last changed 2021-05-04 18:02 by hrik2001.

Messages (1)
msg392809 - (view) Author: Antony Lee (Antony.Lee) * Date: 2021-05-03 14:24
Adding a call/__call__ function to the operator module (where `operator.call(*args, **kwargs)(func) == func(*args, **kwargs)`, similarly to operator.methodcaller) seems consistent with the design with the rest of the operator module.

An actual use case I had for such an operator was collecting a bunch of callables in a list and wanting to dispatch them to concurrent.futures.Executor.map, i.e. something like `executor.map(operator.call, funcs)` (to get the parallelized version of `[func() for func in funcs]`).
History
Date User Action Args
2021-05-04 18:02:14hrik2001setnosy: + hrik2001
2021-05-03 14:24:00Antony.Leecreate