Commit 02c30561 authored by Georg Brandl's avatar Georg Brandl

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.
parent 48952d39
......@@ -46,6 +46,7 @@ defining exceptions is available in the Python Tutorial under
The following exceptions are only used as base classes for other exceptions.
.. XXX document with_traceback()
.. exception:: BaseException
......
This diff is collapsed.
......@@ -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.
......
This diff is collapsed.
......@@ -53,9 +53,9 @@ a complete program; each statement is executed in the namespace of
Under Unix, a complete program can be passed to the interpreter in three forms:
with the :option:`-c` *string* command line option, as a file passed as the
first command line argument, or as standard input. If the file or standard input
is a tty device, the interpreter enters interactive mode; otherwise, it executes
the file as a complete program.
first command line argument, or as standard input. If the file or standard
input is a tty device, the interpreter enters interactive mode; otherwise, it
executes the file as a complete program.
.. _file-input:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment