content_image/762032.jpg
With more than one item, the context managers are processed as if multiple$_{with}$ statements were nested: 

with A() as a, B() as b: SUITE 

is semantically equivalent to: 

with A() as a: with B() as b: SUITE 

Changed in version 3.1: Support for multiple context expressions. 

See also: 

PEP 343 - The “with” statement The specification, background, and examples for the Python with statement. 

## 8.6 Function definitions 

A function definition defines a user-defined function object (see section The standard type hierarchy ): 

<img src='content_image/762032.jpg'>

A function definition is an executable statement. Its execution binds the function name in the current local namespace to a function object (a wrapper around the executable code for the function). This function object contains a reference to the current global namespace as the global namespace to be used when the function is called. 

The function definition does not execute the function body; this gets executed only when the function is called. 2 

A function definition may be wrapped by one or more decorator expressions. Decorator expressions are evaluated when the function is defined, in the scope that contains the function definition. The result must be a callable, which is invoked with the function object as the only argument. The returned value is bound to the function name instead of the function object. Multiple decorators are applied in nested fashion. For example, the following code 

@f1 (arg) @f2 def func(): pass 

is roughly equivalent to 

def func(): pass func=f1(arg)(f2(func)) 

except that the original function is not temporarily bound to the name$_{func}$ . 

