[Python-checkins] r73518 - python/trunk/Lib/contextlib.py

nick.coghlan python-checkins at python.org
Tue Jun 23 12:19:30 CEST 2009


Author: nick.coghlan
Date: Tue Jun 23 12:19:30 2009
New Revision: 73518
Log:
Issue 6288: Update contextlib.nested() docstring to reflect new documentation
Modified:
 python/trunk/Lib/contextlib.py
Modified: python/trunk/Lib/contextlib.py
==============================================================================
--- python/trunk/Lib/contextlib.py	(original)
+++ python/trunk/Lib/contextlib.py	Tue Jun 23 12:19:30 2009
@@ -87,19 +87,17 @@
 
 @contextmanager
 def nested(*managers):
- """Support multiple context managers in a single with-statement.
+ """Combine multiple context managers into a single nested context manager.
 
- Code like this:
-
- with nested(A, B, C) as (X, Y, Z):
- <body>
+ This function has been deprecated in favour of the multiple manager form
+ of the :keyword:`with` statement.
 
- is equivalent to this:
+ The one advantage of this function over the multiple manager form of the
+ :keyword:`with` statement is that argument unpacking allows it to be
+ used with a variable number of context managers as follows:
 
- with A as X:
- with B as Y:
- with C as Z:
- <body>
+ with nested(*managers):
+ do_something()
 
 """
 warn("With-statements now directly support multiple context managers",


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /