Mailing List Archive

[issue13585] Add contextlib.ExitStack
Nick Coghlan <> added the comment:

Latest draft of API is here:

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)
dest = open(destination, 'w')
copy(src, dest)

The example of opening a collection of files remains unchanged (aside from s/ContextStack/ExitStack/).

Also see:

assignee: rhettinger -> ncoghlan
resolution: later ->
title: Add contextlib.CallbackStack -> Add contextlib.ExitStack

Python tracker <>
Python-bugs-list mailing list