This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2016年07月28日 18:30 by terry.reedy, last changed 2022年04月11日 14:58 by admin. This issue is now closed.
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 24595 | merged | terry.reedy, 2021年02月20日 05:14 | |
| PR 24602 | merged | miss-islington, 2021年02月21日 02:34 | |
| PR 24603 | merged | miss-islington, 2021年02月21日 02:34 | |
| Messages (4) | |||
|---|---|---|---|
| msg271577 - (view) | Author: Terry J. Reedy (terry.reedy) * (Python committer) | Date: 2016年07月28日 18:30 | |
https://docs.python.org/3/reference/expressions.html#yield-expressions says "When yield from <expr> is used, it treats the supplied expression as a subiterator. All values produced by that subiterator ...". To me "treats..expression as a subiterator" means that the expression must *be* an iterator, such as returned by iter or calling a generator function. Hence I was surprised upon reading "yield from <non-iterator iterable>" in stdlib code. I confirmed that this usage is correct by trying >>> def g(): yield from (1,2) >>> i = g() >>> next(i), next(i) (1, 2) and then reading the PEP380 Formal Semantics, which begins with "_i = iter(EXPR)". Hence I suggest the following replacement for the quote above: "When yield from <expr> is used, the expression must be an iterable. A subiterator is obtained with iter(<expr>). All values produced by that subiterator ...". Note that 'subiterator' is spelled in the following sentences 'underlying iterable' (which I am not sure I like) and 'sub-iterator' (and 'sub-generator'). I think we should be consistent for at least the two short 'yield from' paragraphs. |
|||
| msg387435 - (view) | Author: Terry J. Reedy (terry.reedy) * (Python committer) | Date: 2021年02月21日 02:33 | |
New changeset 2f9ef514fb24b6a95bd3272885f197752810c107 by Terry Jan Reedy in branch 'master': bpo-27646: Say that 'yield from' expression can be any iterable (GH-24595) https://github.com/python/cpython/commit/2f9ef514fb24b6a95bd3272885f197752810c107 |
|||
| msg387436 - (view) | Author: miss-islington (miss-islington) | Date: 2021年02月21日 02:42 | |
New changeset 089a21f7429a3fd3cf78e3779df724757d346d19 by Miss Islington (bot) in branch '3.8': bpo-27646: Say that 'yield from' expression can be any iterable (GH-24595) https://github.com/python/cpython/commit/089a21f7429a3fd3cf78e3779df724757d346d19 |
|||
| msg387437 - (view) | Author: miss-islington (miss-islington) | Date: 2021年02月21日 02:55 | |
New changeset 7cc58890b3c16c28360a9abe030258426e89fec1 by Miss Islington (bot) in branch '3.9': bpo-27646: Say that 'yield from' expression can be any iterable (GH-24595) https://github.com/python/cpython/commit/7cc58890b3c16c28360a9abe030258426e89fec1 |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:58:34 | admin | set | github: 71833 |
| 2021年02月21日 05:40:52 | terry.reedy | set | status: open -> closed stage: patch review -> resolved resolution: fixed versions: + Python 3.8, Python 3.9 |
| 2021年02月21日 02:55:57 | miss-islington | set | messages: + msg387437 |
| 2021年02月21日 02:42:30 | miss-islington | set | messages: + msg387436 |
| 2021年02月21日 02:34:11 | miss-islington | set | pull_requests: + pull_request23381 |
| 2021年02月21日 02:34:00 | miss-islington | set | nosy:
+ miss-islington pull_requests: + pull_request23380 |
| 2021年02月21日 02:33:39 | terry.reedy | set | messages: + msg387435 |
| 2021年02月20日 05:14:36 | terry.reedy | set | keywords:
+ patch pull_requests: + pull_request23373 |
| 2021年02月19日 13:58:03 | iritkatriel | set | title: yield from expression can be any iterable -> doc: yield from expression can be any iterable versions: + Python 3.10, - Python 3.5, Python 3.6 |
| 2016年07月28日 18:30:50 | terry.reedy | create | |