On 26 March 2018 at 18:35, Roberto MartÃnez <[email protected]> wrote:
> @contextmanager
> def calling(fn, *args, **kwargs):
> try:
> yield
> finally:
> fn(*args, **kwargs)
I'd be more amenable to a proposal along these lines (rather than
adding a parameter to closing), as it more closely resembles the way
that contextlib.ExitStack.callback already works:
with contextlib.ExitStack() as stack:
stack.callback(fn, *args, **kwds)
...
In cases where you just want to call a single operation and don't need
the extra complexity and overhead of the dynamic stack, then it would
be nice to be able to instead write:
with contextlib.callback(fn, *args, **kwds):
...
Cheers,
Nick.
--
Nick Coghlan | [email protected] | Brisbane, Australia
_______________________________________________
Python-ideas mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/