]> granicus.if.org Git - python/commitdiff
Issue 6288: Update contextlib.nested() docstring to reflect new documentation
authorNick Coghlan <ncoghlan@gmail.com>
Tue, 23 Jun 2009 10:19:30 +0000 (10:19 +0000)
committerNick Coghlan <ncoghlan@gmail.com>
Tue, 23 Jun 2009 10:19:30 +0000 (10:19 +0000)
Lib/contextlib.py

index 6fcb5360eb2bdbfa8b7cb2840dc7fb49bbba66dd..a27c86925017f26b8408ec8c6cd60f4e3a9a50bd 100644 (file)
@@ -87,19 +87,17 @@ def contextmanager(func):
 
 @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",