diff --git a/Lib/contextlib.py b/Lib/contextlib.py index 6fcb5360eb2..a27c8692501 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: + This function has been deprecated in favour of the multiple manager form + of the :keyword:`with` statement. - with nested(A, B, C) as (X, Y, Z): - + 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: - is equivalent to this: - - with A as X: - with B as Y: - with C as Z: - + with nested(*managers): + do_something() """ warn("With-statements now directly support multiple context managers",