mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 13:41:24 +00:00 
			
		
		
		
	Issue 6288: Update contextlib.nested() docstring to reflect new documentation
This commit is contained in:
		
							parent
							
								
									94819cf47c
								
							
						
					
					
						commit
						0d8b4e33e7
					
				
					 1 changed files with 8 additions and 10 deletions
				
			
		|  | @ -87,19 +87,17 @@ def helper(*args, **kwds): | |||
| 
 | ||||
| @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): | ||||
|             <body> | ||||
|    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: | ||||
|                     <body> | ||||
|       with nested(*managers): | ||||
|           do_something() | ||||
| 
 | ||||
|     """ | ||||
|     warn("With-statements now directly support multiple context managers", | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Nick Coghlan
						Nick Coghlan