mirror of
https://github.com/python/cpython.git
synced 2025-11-11 14:44:57 +00:00
Merge
This commit is contained in:
commit
7cdb447b56
4 changed files with 12 additions and 2 deletions
|
|
@ -261,6 +261,9 @@ The following exceptions are the exceptions that are usually raised.
|
||||||
raised, and the value returned by the function is used as the
|
raised, and the value returned by the function is used as the
|
||||||
:attr:`value` parameter to the constructor of the exception.
|
:attr:`value` parameter to the constructor of the exception.
|
||||||
|
|
||||||
|
.. versionchanged:: 3.3
|
||||||
|
Added ``value`` attribute and the ability for generator functions to
|
||||||
|
use it to return a value.
|
||||||
|
|
||||||
.. exception:: SyntaxError
|
.. exception:: SyntaxError
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -355,7 +355,7 @@ 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
|
garbage collected), the generator-iterator's :meth:`close` method will be
|
||||||
called, allowing any pending :keyword:`finally` clauses to execute.
|
called, allowing any pending :keyword:`finally` clauses to execute.
|
||||||
|
|
||||||
When ``yield from expression`` is used, it treats the supplied expression as
|
When ``yield from <expr>`` is used, it treats the supplied expression as
|
||||||
a subiterator. All values produced by that subiterator are passed directly
|
a subiterator. All values produced by that subiterator are passed directly
|
||||||
to the caller of the current generator's methods. Any values passed in with
|
to the caller of the current generator's methods. Any values passed in with
|
||||||
:meth:`send` and any exceptions passed in with :meth:`throw` are passed to
|
:meth:`send` and any exceptions passed in with :meth:`throw` are passed to
|
||||||
|
|
@ -369,6 +369,9 @@ the yield expression. It can be either set explicitly when raising
|
||||||
:exc:`StopIteration`, or automatically when the sub-iterator is a generator
|
:exc:`StopIteration`, or automatically when the sub-iterator is a generator
|
||||||
(by returning a value from the sub-generator).
|
(by returning a value from the sub-generator).
|
||||||
|
|
||||||
|
.. versionchanged:: 3.3
|
||||||
|
Added ``yield from <expr>`` to delegate control flow to a subiterator
|
||||||
|
|
||||||
The parentheses can be omitted when the :keyword:`yield` expression is the
|
The parentheses can be omitted when the :keyword:`yield` expression is the
|
||||||
sole expression on the right hand side of an assignment statement.
|
sole expression on the right hand side of an assignment statement.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -470,10 +470,13 @@ 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
|
garbage collected), the generator-iterator's :meth:`close` method will be
|
||||||
called, allowing any pending :keyword:`finally` clauses to execute.
|
called, allowing any pending :keyword:`finally` clauses to execute.
|
||||||
|
|
||||||
When ``yield from expression`` is used, it treats the supplied expression as
|
When ``yield from <expr>`` is used, it treats the supplied expression as
|
||||||
a subiterator, producing values from it until the underlying iterator is
|
a subiterator, producing values from it until the underlying iterator is
|
||||||
exhausted.
|
exhausted.
|
||||||
|
|
||||||
|
.. versionchanged:: 3.3
|
||||||
|
Added ``yield from <expr>`` to delegate control flow to a subiterator
|
||||||
|
|
||||||
For full details of :keyword:`yield` semantics, refer to the :ref:`yieldexpr`
|
For full details of :keyword:`yield` semantics, refer to the :ref:`yieldexpr`
|
||||||
section.
|
section.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -224,6 +224,7 @@ it provides better information about where they were actually defined, and
|
||||||
how they might be accessible from the global scope.
|
how they might be accessible from the global scope.
|
||||||
|
|
||||||
Example with (non-bound) methods::
|
Example with (non-bound) methods::
|
||||||
|
|
||||||
>>> class C:
|
>>> class C:
|
||||||
... def meth(self):
|
... def meth(self):
|
||||||
... pass
|
... pass
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue