summaryrefslogtreecommitdiffstats
path: root/Doc/reference/expressions.rst
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2007-09-07 17:52:53 (GMT)
committerGeorg Brandl <georg@python.org>2007-09-07 17:52:53 (GMT)
commit02c305614d0dccee7deeda471942992c72cdc8f1 (patch)
tree3977f1829091997de340dcdd75447589323b5820 /Doc/reference/expressions.rst
parent48952d397bb83b67924325447ddbbe955bb87c7b (diff)
downloadcpython-02c305614d0dccee7deeda471942992c72cdc8f1.zip
cpython-02c305614d0dccee7deeda471942992c72cdc8f1.tar.gz
cpython-02c305614d0dccee7deeda471942992c72cdc8f1.tar.bz2
Finish the first pass of the language reference update.
Document extended iterable unpacking, raising and catching exceptions, class decorators, etc. A few notable things are not documented yet, I've added XXX comments about that.
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.