class documentation
A list of callables that can be called like a single callable.
The simplest usecase of this minitool is single-shot usage like:
res = ListOfCallables(callable_or_list_of_callables)(args)
as a one-line simplification of either:
if callable(callable_or_list_of_callables):
res = [callable_or_list_of_callables(args)]
else:
res = [c(args) for c in callable_or_list_of_callables]
or:
try:
res = [c(args) for c in callable_or_list_of_callables]
except TypeError:
res = [callable_or_list_of_callables(args)]
| Method | __call__ |
call each element of the list and return a list of return values |
| Method | __init__ |
return a list of callables as a callable itself. |
| Instance Variable | _input |
Undocumented |
return a list of callables as a callable itself.
callback can be a callable or a list (or iterable) of
callables. Otherwise a ValueError exception is raised.
Possible usecase: termination callback(s) of CMA-ES:
self.opts['termination_callback'](self)
becomes:
ListOfCallables(self.opts['termination_callback'])(self)