def list_call_and_update(modules, *args, **kwargs): """Maps `call_and_update` across a list.""" modules_out = [] for module in modules: if not isinstance(args, tuple): args = (args, ) args, new_module = api.call_and_update(module, *args, **kwargs) # pylint: disable=assignment-from-no-return modules_out.append(new_module) return args, modules_out
def tuple_call_and_update(tupl, *args, **kwargs): """Maps `call_and_update` across a tuple.""" out, new_tupl = zip( *[api.call_and_update(t, *args, **kwargs) for t in tupl]) return (tuple.__new__(tupl.__class__, out), tuple.__new__(tupl.__class__, new_tupl))