diff options
Diffstat (limited to 'Lib/contextlib.py')
-rw-r--r-- | Lib/contextlib.py | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/Lib/contextlib.py b/Lib/contextlib.py index 6fcb5360eb..a27c869250 100644 --- a/Lib/contextlib.py +++ b/Lib/contextlib.py @@ -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", |