-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
gh-107017: removed mention that C does it the same way #107020
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
Conversation
Don't assume the reader knows the C language, especially in the tutorial.
the reader may not know any control flow statements or other languages, also the "twists" may feel too intimidating
Doc/tutorial/controlflow.rst
Outdated
@@ -4,8 +4,8 @@ | |||
More Control Flow Tools | |||
*********************** | |||
|
|||
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.
Choose a reason for 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".
Doc/tutorial/controlflow.rst
Outdated
: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.
Choose a reason for 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.
Doc/tutorial/controlflow.rst
Outdated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"... that we will encounter..."
Doc/tutorial/controlflow.rst
Outdated
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.
Choose a reason for 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.
Doc/tutorial/controlflow.rst
Outdated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exemplified in
Doc/tutorial/controlflow.rst
Outdated
@@ -166,7 +166,7 @@ arguments. In chapter :ref:`tut-structures`, we will discuss in more detail abo | |||
The :keyword:`break` statement breaks out of the innermost enclosing | |||
: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.
Choose a reason for 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.)
Thanks @JakubDotPy for the PR, and @hugovk for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11, 3.12. |
…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. |
GH-107098 is a backport of this pull request to the 3.11 branch. |
…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]>
Don't assume the reader knows the C language, especially in the tutorial.
📚 Documentation preview 📚: https://cpython-previews--107020.org.readthedocs.build/