mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
[3.13] gh-135171: Update documentation for the generator expression (GH-135351) (GH-135525)
Some checks are pending
Tests / Check if Autoconf files are up to date (push) Blocked by required conditions
Tests / Windows MSI (push) Blocked by required conditions
Tests / (push) Blocked by required conditions
Tests / Change detection (push) Waiting to run
Tests / Docs (push) Blocked by required conditions
Tests / Check if the ABI has changed (push) Blocked by required conditions
Tests / Check if generated files are up to date (push) Blocked by required conditions
Tests / Ubuntu SSL tests with OpenSSL (push) Blocked by required conditions
Tests / WASI (push) Blocked by required conditions
Tests / Hypothesis tests on Ubuntu (push) Blocked by required conditions
Tests / Address sanitizer (push) Blocked by required conditions
Tests / CIFuzz (push) Blocked by required conditions
Tests / All required checks pass (push) Blocked by required conditions
Lint / lint (push) Waiting to run
Some checks are pending
Tests / Check if Autoconf files are up to date (push) Blocked by required conditions
Tests / Windows MSI (push) Blocked by required conditions
Tests / (push) Blocked by required conditions
Tests / Change detection (push) Waiting to run
Tests / Docs (push) Blocked by required conditions
Tests / Check if the ABI has changed (push) Blocked by required conditions
Tests / Check if generated files are up to date (push) Blocked by required conditions
Tests / Ubuntu SSL tests with OpenSSL (push) Blocked by required conditions
Tests / WASI (push) Blocked by required conditions
Tests / Hypothesis tests on Ubuntu (push) Blocked by required conditions
Tests / Address sanitizer (push) Blocked by required conditions
Tests / CIFuzz (push) Blocked by required conditions
Tests / All required checks pass (push) Blocked by required conditions
Lint / lint (push) Waiting to run
gh-135171: Update documentation for the generator expression (GH-135351)
* gh-135171: Update documentation for the generator expression
Document that the iterator for the leftmost "for" clause is created
immediately.
* Update Doc/reference/expressions.rst
---------
(cherry picked from commit 8979d3afe3
)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Brian Skinn <brian.skinn@gmail.com>
This commit is contained in:
parent
15340775f8
commit
a80d47ecb1
2 changed files with 5 additions and 2 deletions
|
@ -407,8 +407,9 @@ brackets or curly braces.
|
|||
Variables used in the generator expression are evaluated lazily when the
|
||||
:meth:`~generator.__next__` method is called for the generator object (in the same
|
||||
fashion as normal generators). However, the iterable expression in the
|
||||
leftmost :keyword:`!for` clause is immediately evaluated, so that an error
|
||||
produced by it will be emitted at the point where the generator expression
|
||||
leftmost :keyword:`!for` clause is immediately evaluated, and the
|
||||
:term:`iterator` is immediately created for that iterable, so that an error
|
||||
produced while creating the iterator will be emitted at the point where the generator expression
|
||||
is defined, rather than at the point where the first value is retrieved.
|
||||
Subsequent :keyword:`!for` clauses and any filter condition in the leftmost
|
||||
:keyword:`!for` clause cannot be evaluated in the enclosing scope as they may
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
Document that the :term:`iterator` for the leftmost :keyword:`!for` clause
|
||||
in the generator expression is created immediately.
|
Loading…
Add table
Add a link
Reference in a new issue