Skip to content

bpo-46033: Clarify for-statement execution #30025

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

michcio1234
Copy link
Contributor

@michcio1234 michcio1234 commented Dec 10, 2021

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 modified this text to be - in my opinion - cleaner.

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.

https://bugs.python.org/issue46033

@terryjreedy
Copy link
Member

Please let us know when you have signed the CLA. It might take a few days to be recorded.

@michcio1234
Copy link
Contributor Author

@terryjreedy done. Forgot to check myself.

@python python deleted a comment from the-knights-who-say-ni Dec 14, 2021
@michcio1234
Copy link
Contributor Author

michcio1234 commented Jan 3, 2022

@terryjreedy I added news entry to make Azure Pipelines PR check green. CLA is also signed.

@JelleZijlstra
Copy link
Member

@michcio1234 there is a merge conflict now, could you take a look?

Also, I don't think this change needs a NEWS entry. I added the "skip news" label so CI won't fail if you remove the NEWS entry you added.

@JelleZijlstra JelleZijlstra self-assigned this Apr 2, 2022
@terryjreedy terryjreedy changed the title bpo-46033: Remove duplicated sentence from for statement docs bpo-46033: Clarify for-statement execution Apr 2, 2022
terryjreedy
terryjreedy previously approved these changes Apr 2, 2022
Copy link
Member

@terryjreedy terryjreedy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the change was to just remove a sentence, then no news would be needed. But we did something else, and I made more edits to blend with the other, conflicting merge. Hence I changed both title and news.

I think this is ready, but please read to check.

Note: the other addition was not backported, so this cannot be either.

terryjreedy and others added 2 commits April 2, 2022 18:22
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
@terryjreedy terryjreedy dismissed their stale review April 2, 2022 22:43

Jelle found more improvements

@terryjreedy
Copy link
Member

I will re-approve with 2 links added (if you agree) and removal of sentence as suggested.

@terryjreedy
Copy link
Member

Will merge after checking generated .html on my machine.

@terryjreedy terryjreedy merged commit 281f980 into python:main Apr 3, 2022
@michcio1234
Copy link
Contributor Author

@terryjreedy @JelleZijlstra thank you very much for taking care of this and sorry for not responding lately. Glad that something useful came out of this. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir skip news
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants