Repository navigation
Conversation
- Remove the sentence that sparked some confusion, which starts "As the loop executes ..." - The opening of "else Clauses on Loops" now states that the `else` is paired with the `for` or `while` loop keyword, not with an internal `break` -- this small change better prepares readers for the possibility of `while-else` and `for-else` without a `break` (which is rare but valid). - The final paragraph of this doc section has been reworded, so that it is clear that it, and the section above it, are both analogies which can help readers understand `for-else` and `while-else`. The precise rules for what the `else` clause does are properly stated above.
Documentation build overview
|
sirosen
commented
Nov 30, 2026
| occurs, and a loop's ``else`` clause runs when no ``break`` occurs. For more on | ||
| the ``try`` statement and exceptions, see :ref:`tut-handling`. | ||
| The :keyword:`!else` clause of a :keyword:`!for` loop can also be understood | ||
| similarly to the :keyword:`!else` clause of a :keyword:`try` statement: a |
Contributor
Author
There was a problem hiding this comment.
I'm now staring at the fact that this sentence is using the passive voice.
An alternative:
An alternative way to understand the
elseclause of aforloop is to compare it to theelseclause of atrystatement: ...
I'm not sure which is better. (The passive voice was used. But was it used well? 😛 )
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Remove the sentence that sparked some confusion, which starts "As the loop executes ..."
The opening of "else Clauses on Loops" now states that the
elseis paired with thefororwhileloop keyword, not with an internalbreak-- this small change better prepares readers for the possibility ofwhile-elseandfor-elsewithout abreak(which is rare but valid).The final paragraph of this doc section has been reworded, so that it is clear that it, and the section above it, are both analogies which can help readers understand
for-elseandwhile-else. The precise rules for what theelseclause does are properly stated above.@picnixz, let me know if you think we should make more changes. :)
I think that if you look at the whole section with these updates, it reads pretty well now.