GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — gh-107017: removed mention that C does it the same way by JakubDotPy · Pull Request #107020 · python/cpython Conversation
|
|
|
||
| Besides the :keyword:`while` statement just introduced, Python uses the usual | ||
| flow control statements known from other languages, with some twists. | ||
| Besides the :keyword:`while` statement just introduced, Python uses a few more |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
"As well as" would be more idiomatic English than "besides".
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| :keyword:`for` or :keyword:`while` loop. | ||
|
|
||
| Loop statements may have an :keyword:`!else` clause; it is executed when the loop | ||
| The :keyword:`for` loop statements may have an extra :keyword:`!else` clause; it is executed when the loop |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I think the line length needs to be checked here.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| Besides the :keyword:`while` statement just introduced, Python uses the usual | ||
| flow control statements known from other languages, with some twists. | ||
| Besides the :keyword:`while` statement just introduced, Python uses a few more | ||
| that will be introduced in this chapter. |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
"... that we will encounter..."
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| The :keyword:`for` loop statements may have an extra :keyword:`!else` clause; | ||
| it is executed when the loop terminates through exhaustion of the iterable | ||
| (with :keyword:`for`) or when the condition becomes false (with :keyword:`while`), | ||
| but not when the loop is terminated by a :keyword:`break` statement. |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I find the original language here rather hard to parse because the concepts are quite unfamiliar (a loop that terminates through exhaustion of an iterable...).
Perhaps:
A for or while loop can include an else clause.
In a for loop, the else clause is executed after the loop reaches its final iteration. In a while loop, it's executed after the loop's condition becomes false.
In either kind of loop, the else clause is not executed if the loop was terminated by a break.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| it is executed when the loop terminates through exhaustion of the iterable | ||
| (with :keyword:`for`) or when the condition becomes false (with :keyword:`while`), | ||
| but not when the loop is terminated by a :keyword:`break` statement. | ||
| This is exemplified by the following loop, which searches for prime numbers:: |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
exemplified in
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| :keyword:`for` or :keyword:`while` loop. | ||
|
|
||
| Loop statements may have an :keyword:`!else` clause; it is executed when the loop | ||
| The :keyword:`for` loop statements may have an extra :keyword:`!else` clause; it is executed when the loop |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This just seems bad. You restricted it to for statements, but it also applies to while statements. And the else clause isn't really "extra" (I even checked some dictionaries, they all defined it like "added to an existing or usual amount or number; additional. Example: they offered him an extra thirty-five cents an hour". And loop statements can only have one else clause.)
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thanks @JakubDotPy for the PR, and @hugovk for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11, 3.12. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…H-107020) (cherry picked from commit 9629d44) Co-authored-by: Jakub Červinka <[email protected]>
|
GH-107097 is a backport of this pull request to the 3.12 branch. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
GH-107098 is a backport of this pull request to the 3.11 branch. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…H-107020) (cherry picked from commit 9629d44) Co-authored-by: Jakub Červinka <[email protected]>
) (#107097) Co-authored-by: Jakub Červinka <[email protected]>
) (#107098) Co-authored-by: Jakub Červinka <[email protected]>
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.