Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Bugs

[issue13585] Add contextlib.ExitStack



Python bugs RSS feed   Index | Next | Previous | View Threaded

report at bugs

May 1, 2012, 5:22 AM

Post #1 of 1 (96 views)
[issue13585] Add contextlib.ExitStack

Nick Coghlan <ncoghlan [at] gmail> 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)
dest = open(destination, 'w')
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 <report [at] bugs>
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com

Python bugs RSS feed   Index | Next | Previous | View Threaded

Interested in having your list archived? Contact Gossamer Threads
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.