mirror of
https://github.com/jazzband/contextlib2.git
synced 2026-03-17 06:00:23 +00:00
Add link back to original tracker issue, fix typo noticed by Chris Neugebauer
This commit is contained in:
parent
c1d261921b
commit
dbc0c6d23f
2 changed files with 4 additions and 3 deletions
|
|
@ -141,13 +141,14 @@ class closing(object):
|
|||
self.thing.close()
|
||||
|
||||
|
||||
# Inspired by discussions on http://bugs.python.org/issue13585
|
||||
class ContextStack(object):
|
||||
"""Context for programmatic management of resource cleanup
|
||||
"""Context manager for programmatic management of resource cleanup
|
||||
|
||||
For example:
|
||||
|
||||
with ContextStack() as stack:
|
||||
files = [stack.enter_context(fname) for fname in filenames]
|
||||
files = [stack.enter_context(open(fname)) for fname in filenames]
|
||||
# All opened files will automatically be closed at the end of
|
||||
# the with statement, even if attempts to open files later
|
||||
# in the list throw an exception
|
||||
|
|
|
|||
|
|
@ -199,7 +199,7 @@ API Reference
|
|||
statement as follows::
|
||||
|
||||
with ContextStack() as stack:
|
||||
files = [stack.enter_context(fname) for fname in filenames]
|
||||
files = [stack.enter_context(open(fname)) for fname in filenames]
|
||||
# All opened files will automatically be closed at the end of
|
||||
# the with statement, even if attempts to open files later
|
||||
# in the list throw an exception
|
||||
|
|
|
|||
Loading…
Reference in a new issue