8000 gh-107017: removed mention that C does it the same way by JakubDotPy · Pull Request #107020 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

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

Merged
merged 8 commits into from
Jul 23, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fixed typo and a line length
  • Loading branch information
JakubDotPy committed Jul 22, 2023
commit 6acff0ccbaa21716c6f4a96afc47bbf7e80f680b
12 changes: 6 additions & 6 deletions Doc/tutorial/controlflow.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ More Control Flow Tools
***********************

As well as the :keyword:`while` statement just introduced, Python uses a few more
that will we will encounter in this chapter.
that we will encounter in this chapter.


.. _tut-if:
Expand Down Expand Up @@ -166,11 +166,11 @@ 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.

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. This is exemplified by the
following loop, which searches for prime numbers::
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 88C1 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.

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


>>> for n in range(2, 10):
... for x in range(2, n):
Expand Down
0