Nick Coghlan <ncogh...@gmail.com> added the comment: Latest draft of API is here: http://contextlib2_dev.readthedocs.org/en/latest/index.html#contextlib2.ExitStack
An updated version of the "I forgot I could use multiple context managers in a with statement" example: with ExitStack() as stack: src = open(source) stack.callback(src.close) dest = open(destination, 'w') stack.callback(dest.close) copy(src, dest) The example of opening a collection of files remains unchanged (aside from s/ContextStack/ExitStack/). Also see: http://contextlib2_dev.readthedocs.org/en/latest/index.html#replacing-any-use-of-try-finally-and-flag-variables ---------- assignee: rhettinger -> ncoghlan resolution: later -> title: Add contextlib.CallbackStack -> Add contextlib.ExitStack _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue13585> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com