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.

classification
Title: Duplicated sentence in for statement documentation
Type: enhancement Stage: resolved
Components: Documentation Versions: Python 3.10
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: docs@python, michcio1234, python-dev, terry.reedy, veky
Priority: normal Keywords: patch

Created on 2021-12-10 10:42 by michcio1234, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 30025 merged python-dev, 2021-12-10 11:05
Messages (5)
msg408189 - (view) Author: Michał D (michcio1234) * Date: 2021-12-10 10:42
In for statement description, there seem to be two sentences meant to mean the same:

> The suite is then executed once for each item provided by the iterator, in the order returned by the iterator. Each item in turn is assigned to the target list using the standard rules for assignments (see Assignment statements), and then the suite is executed.

(from https://docs.python.org/3/reference/compound_stmts.html#the-for-statement)

I believe only one of these sentences should be kept (probably the second one).

If I am wrong, and the current version is actually correct, then it is unclear - to me it sounds like the iterator is iterated through twice, and suite is executed twice for each item.
msg408193 - (view) Author: Vedran Čačić (veky) * Date: 2021-12-10 11:44
How about adding the words "More precisely," at the beginning of the second sentence?
msg409600 - (view) Author: Michał D (michcio1234) * Date: 2022-01-03 18:09
Please see the changes I suggested in my PR.
msg409619 - (view) Author: Vedran Čačić (veky) * Date: 2022-01-03 20:44
Yes, it's ok. The only slight problem is that is suggests that first item is somehow special, but later it is explained that in fact it is not. :-) I would say "_Each_ item ..." (instead of "First") and without the "this is repeated for every item..." at the end, but as I said, this is also fine.
msg416608 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2022-04-03 00:52
New changeset 281f980d354d1709018a2dc77f79388faf3e56c0 by Michał D in branch 'main':
bpo-46033: Clarify for-statement execution (GH-30025)
https://github.com/python/cpython/commit/281f980d354d1709018a2dc77f79388faf3e56c0
History
Date User Action Args
2022-04-11 14:59:53adminsetgithub: 90191
2022-04-03 00:54:41terry.reedysetstatus: open -> closed
type: enhancement
resolution: fixed
stage: patch review -> resolved
2022-04-03 00:52:27terry.reedysetnosy: + terry.reedy
messages: + msg416608
2022-01-03 20:44:20vekysetmessages: + msg409619
2022-01-03 18:09:14michcio1234setmessages: + msg409600
2021-12-10 11:44:18vekysetnosy: + veky
messages: + msg408193
2021-12-10 11:05:16python-devsetkeywords: + patch
nosy: + python-dev

pull_requests: + pull_request28249
stage: patch review
2021-12-10 10:42:42michcio1234create