From 5742c7eb471d956bd0455c29554e34a3cbc48adb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20=C4=8Cervinka?= Date: Sat, 22 Jul 2023 14:14:04 +0200 Subject: [PATCH 1/8] removed mention that C does it the same way Don't assume the reader knows the C language, especially in the tutorial. --- Doc/tutorial/controlflow.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/tutorial/controlflow.rst b/Doc/tutorial/controlflow.rst index e140f51f1dda78..56ebce5271c728 100644 --- a/Doc/tutorial/controlflow.rst +++ b/Doc/tutorial/controlflow.rst @@ -163,7 +163,7 @@ arguments. In chapter :ref:`tut-structures`, we will discuss in more detail abo :keyword:`!break` and :keyword:`!continue` Statements, and :keyword:`!else` Clauses on Loops ============================================================================================ -The :keyword:`break` statement, like in C, breaks out of the innermost enclosing +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 From 67534f2bf3aa04617d3c67f1b74e27f9743e20e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20=C4=8Cervinka?= Date: Sat, 22 Jul 2023 15:00:50 +0200 Subject: [PATCH 2/8] there are no "usual" flow control statements the reader may not know any control flow statements or other languages, also the "twists" may feel too intimidating --- Doc/tutorial/controlflow.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Doc/tutorial/controlflow.rst b/Doc/tutorial/controlflow.rst index 56ebce5271c728..4b2c7ba60657ef 100644 --- a/Doc/tutorial/controlflow.rst +++ b/Doc/tutorial/controlflow.rst @@ -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 +that will be introduced in this chapter. .. _tut-if: @@ -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 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 From a588abc8526fdc455f8c2afe692fb75f0ec27d39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20=C4=8Cervinka?= Date: Sat, 22 Jul 2023 15:42:42 +0200 Subject: [PATCH 3/8] implemented suggestions --- Doc/tutorial/controlflow.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/tutorial/controlflow.rst b/Doc/tutorial/controlflow.rst index 4b2c7ba60657ef..c969facd3bdfcb 100644 --- a/Doc/tutorial/controlflow.rst +++ b/Doc/tutorial/controlflow.rst @@ -4,8 +4,8 @@ More Control Flow Tools *********************** -Besides the :keyword:`while` statement just introduced, Python uses a few more -that will be introduced in this chapter. +As well as the :keyword:`while` statement just introduced, Python uses a few more +that will we will encounter in this chapter. .. _tut-if: From 6acff0ccbaa21716c6f4a96afc47bbf7e80f680b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20=C4=8Cervinka?= Date: Sat, 22 Jul 2023 15:55:30 +0200 Subject: [PATCH 4/8] fixed typo and a line length --- Doc/tutorial/controlflow.rst | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Doc/tutorial/controlflow.rst b/Doc/tutorial/controlflow.rst index c969facd3bdfcb..6504600585c218 100644 --- a/Doc/tutorial/controlflow.rst +++ b/Doc/tutorial/controlflow.rst @@ -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: @@ -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. +This is exemplified by the following loop, which searches for prime numbers:: >>> for n in range(2, 10): ... for x in range(2, n): From 5d08a1b96196e4b1b500436b800c8a234e68f3b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20=C4=8Cervinka?= Date: Sat, 22 Jul 2023 16:37:17 +0200 Subject: [PATCH 5/8] better structuring of the "else" explanation --- Doc/tutorial/controlflow.rst | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/Doc/tutorial/controlflow.rst b/Doc/tutorial/controlflow.rst index 6504600585c218..963f179421c79d 100644 --- a/Doc/tutorial/controlflow.rst +++ b/Doc/tutorial/controlflow.rst @@ -166,11 +166,18 @@ 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:: +A :keyword:`for` or :keyword:`while` loop can include an else clause. + +In a :keyword:`for` loop, the :keyword:`!else` clause is executed +after the loop reaches its final iteration. + +In a :keyword:`while` loop, it's executed after the loop's condition becomes false. + +In either kind of loop, the :keyword:`!else` clause is **not** executed +if the loop was terminated by a :keyword:`break`. + +This is exemplified in the following :keyword:`for` loop, +which searches for prime numbers:: >>> for n in range(2, 10): ... for x in range(2, n): From e4f676a827d28d73e2cb54da9530417a786a3f93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20=C4=8Cervinka?= Date: Sat, 22 Jul 2023 16:42:43 +0200 Subject: [PATCH 6/8] removed links --- Doc/tutorial/controlflow.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/tutorial/controlflow.rst b/Doc/tutorial/controlflow.rst index 963f179421c79d..f02cc8c7ea471c 100644 --- a/Doc/tutorial/controlflow.rst +++ b/Doc/tutorial/controlflow.rst @@ -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. -A :keyword:`for` or :keyword:`while` loop can include an else clause. +A for or while loop can include an else clause. In a :keyword:`for` loop, the :keyword:`!else` clause is executed after the loop reaches its final iteration. From 9c34614654e9d1b1f2bdfe08e2d13e755efa2156 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20=C4=8Cervinka?= Date: Sat, 22 Jul 2023 16:52:53 +0200 Subject: [PATCH 7/8] added keyword formatting --- Doc/tutorial/controlflow.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/tutorial/controlflow.rst b/Doc/tutorial/controlflow.rst index f02cc8c7ea471c..2f5c330ad7e828 100644 --- a/Doc/tutorial/controlflow.rst +++ b/Doc/tutorial/controlflow.rst @@ -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. -A for or while loop can include an else clause. +A :keyword:`!for` or :keyword:`!while` loop can include an :keyword:`!else` clause. In a :keyword:`for` loop, the :keyword:`!else` clause is executed after the loop reaches its final iteration. From 8f0883826d6a35c8f7412f86e4760d8efb0cace1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20=C4=8Cervinka?= Date: Sat, 22 Jul 2023 16:58:00 +0200 Subject: [PATCH 8/8] removed link --- Doc/tutorial/controlflow.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/tutorial/controlflow.rst b/Doc/tutorial/controlflow.rst index 2f5c330ad7e828..138d87f892e891 100644 --- a/Doc/tutorial/controlflow.rst +++ b/Doc/tutorial/controlflow.rst @@ -176,7 +176,7 @@ In a :keyword:`while` loop, it's executed after the loop's condition becomes fal In either kind of loop, the :keyword:`!else` clause is **not** executed if the loop was terminated by a :keyword:`break`. -This is exemplified in the following :keyword:`for` loop, +This is exemplified in the following :keyword:`!for` loop, which searches for prime numbers:: >>> for n in range(2, 10):