Skip to content
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

gh-107017: removed mention that C does it the same way #107020

Merged
merged 8 commits into from
Jul 23, 2023

Conversation

JakubDotPy
Copy link
Contributor

@JakubDotPy JakubDotPy commented Jul 22, 2023

Don't assume the reader knows the C language, especially in the tutorial.


📚 Documentation preview 📚: https://cpython-previews--107020.org.readthedocs.build/

Don't assume the reader knows the C language, especially in the tutorial.
@cpython-cla-bot
Copy link

cpython-cla-bot bot commented Jul 22, 2023

All commit authors signed the Contributor License Agreement.
CLA signed

the reader may not know any control flow statements or other languages,
also the "twists" may feel too intimidating
@@ -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
Copy link
Contributor

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".

: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
Copy link
Contributor

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.

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.
Copy link
Contributor

Choose a reason for hiding this comment

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

"... that we will encounter..."

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.
Copy link
Contributor

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.

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::
Copy link
Contributor

Choose a reason for hiding this comment

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

exemplified in

@@ -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
Copy link
Contributor

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.)

@hugovk hugovk added needs backport to 3.11 only security fixes needs backport to 3.12 bug and security fixes labels Jul 23, 2023
@hugovk hugovk merged commit 9629d44 into python:main Jul 23, 2023
17 checks passed
@miss-islington
Copy link
Contributor

Thanks @JakubDotPy for the PR, and @hugovk for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11, 3.12.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jul 23, 2023
@bedevere-bot
Copy link

GH-107097 is a backport of this pull request to the 3.12 branch.

@bedevere-bot bedevere-bot removed the needs backport to 3.12 bug and security fixes label Jul 23, 2023
@bedevere-bot
Copy link

GH-107098 is a backport of this pull request to the 3.11 branch.

@bedevere-bot bedevere-bot removed the needs backport to 3.11 only security fixes label Jul 23, 2023
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jul 23, 2023
hugovk pushed a commit that referenced this pull request Jul 23, 2023
hugovk pushed a commit that referenced this pull request Jul 23, 2023
@JakubDotPy JakubDotPy deleted the tutorial-docs-improvement branch July 23, 2023 10:48
jtcave pushed a commit to jtcave/cpython that referenced this pull request Jul 23, 2023
mementum pushed a commit to mementum/cpython that referenced this pull request Jul 23, 2023
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.

6 participants