Changeset 388 for python/vendor/current/Lib/contextlib.py
- Timestamp:
- Mar 19, 2014, 11:11:30 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
python/vendor/current/Lib/contextlib.py
r2 r388 3 3 import sys 4 4 from functools import wraps 5 from warnings import warn 5 6 6 7 __all__ = ["contextmanager", "nested", "closing"] … … 87 88 @contextmanager 88 89 def nested(*managers): 89 """ Support multiple context managers in a single with-statement.90 """Combine multiple context managers into a single nested context manager. 90 91 91 Code like this: 92 This function has been deprecated in favour of the multiple manager form 93 of the with statement. 92 94 93 with nested(A, B, C) as (X, Y, Z): 94 <body> 95 The one advantage of this function over the multiple manager form of the 96 with statement is that argument unpacking allows it to be 97 used with a variable number of context managers as follows: 95 98 96 is equivalent to this: 97 98 with A as X: 99 with B as Y: 100 with C as Z: 101 <body> 99 with nested(*managers): 100 do_something() 102 101 103 102 """ 103 warn("With-statements now directly support multiple context managers", 104 DeprecationWarning, 3) 104 105 exits = [] 105 106 vars = []
Note:
See TracChangeset
for help on using the changeset viewer.