summaryrefslogtreecommitdiffstats
path: root/Doc/reference/expressions.rst
diff options
context:
space:
mode:
Diffstat (limited to 'Doc/reference/expressions.rst')
-rw-r--r--Doc/reference/expressions.rst12
1 files changed, 12 insertions, 0 deletions
diff --git a/Doc/reference/expressions.rst b/Doc/reference/expressions.rst
index 33fbeec..4d2ec9a 100644
--- a/Doc/reference/expressions.rst
+++ b/Doc/reference/expressions.rst
@@ -183,6 +183,9 @@ by considering each of the :keyword:`for` or :keyword:`if` clauses a block,
nesting from left to right, and evaluating the expression to produce an element
each time the innermost block is reached.
+Note that the comprehension is executed in a separate scope, so names assigned
+to in the target list don't "leak" in the enclosing scope.
+
.. _lists:
@@ -340,6 +343,12 @@ suspended. The only difference is that a generator function cannot control
where should the execution continue after it yields; the control is always
transfered to the generator's caller.
+The :keyword:`yield` statement is allowed in the :keyword:`try` clause of a
+:keyword:`try` ... :keyword:`finally` construct. If the generator is not
+resumed before it is finalized (by reaching a zero reference count or by being
+garbage collected), the generator-iterator's :meth:`close` method will be
+called, allowing any pending :keyword:`finally` clauses to execute.
+
.. index:: object: generator
The following generator's methods can be used to control the execution of a
@@ -428,6 +437,9 @@ generator functions::
.. seealso::
+ :pep:`0255` - Simple Generators
+ The proposal for adding generators and the :keyword:`yield` statement to Python.
+
:pep:`0342` - Coroutines via Enhanced Generators
The proposal to enhance the API and syntax of generators, making them
usable as simple coroutines.