slicing is in general equivalent to assignment of an empty slice of the right type (but even this is determined by the sliced object). 

Changed in version 3.2: Previously it was illegal to delete a name from the local namespace if it occurs as a free variable in a nested block. 

## 7.6 The return statement 

return_stmt ::= "return" [ expression_list ] 

$_{return}$may only occur syntactically nested in a function definition, not within a nested class definition. 

If an expression list is present, it is evaluated, else None is substituted. 

$_{return}$leaves the current function call with the expression list (or$_{None}$ ) as return value. 

When$_{return}$passes control out of a$_{try}$ statement with a$_{finally}$clause, that$_{finally}$clause is executed before really leaving the function. 

In a generator function, the return statement indicates that the generator is done and will cause StopIteration to be raised. The returned value (if any) is used as an argument to construct$_{StopIteration}$ and becomes the StopIteration.value attribute. 

In an asynchronous generator function, an empty $_{return}$statement indicates that the asynchronous generator is done and will cause$_{StopAsyncIteration}$to be raised. A non-empty$_{return}$statement is a syntax error in an asynchronous generator function. 

## 7.7 The yield statement 

yield_stmt ::= yield_expression 

A $_{yield}$statement is semantically equivalent to a yield expression . The yield statement can be used to omit the parentheses that would otherwise be required in the equivalent yield expression statement. For example, the yield statements 

yield <expr> yield from <expr> 

are equivalent to the yield expression statements 

( yield <expr>) ( yield from <expr>) 

Yield expressions and statements are only used when defining a generator function, and are only used in the body of the generator function. Using yield in a function definition is sufficient to cause that definition to create a generator function instead of a normal function. 

For full details of$_{yield}$ semantics, refer to the Yield expressions section. 

