https://github.com/python/cpython/commit/7c39f74251dea55ab5dc4bc2a1ac4f2db804808b
commit: 7c39f74251dea55ab5dc4bc2a1ac4f2db804808b
branch: 3.12
author: Miss Islington (bot) <[email protected]>
committer: Yhg1s <[email protected]>
date: 2024-09-30T14:17:16-07:00
summary:

[3.12] Docs: for for/else clarify that return or raise also skip the else 
(GH-124591) (#124660)

Docs: for for/else clarify that return or raise also skip the else (GH-124591)

(cherry picked from commit 5329d1b74a86b3a22ff36f7976bfe720ee06d10d)

Co-authored-by: Ned Batchelder <[email protected]>
Co-authored-by: Jelle Zijlstra <[email protected]>

files:
M Doc/tutorial/controlflow.rst

diff --git a/Doc/tutorial/controlflow.rst b/Doc/tutorial/controlflow.rst
index c97c65f7a3988e..fd765e58ff2485 100644
--- a/Doc/tutorial/controlflow.rst
+++ b/Doc/tutorial/controlflow.rst
@@ -209,8 +209,10 @@ after the loop finishes its final iteration, that is, if 
no break occurred.
 
 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`.
+In either kind of loop, the :keyword:`!else` clause is **not** executed if the
+loop was terminated by a :keyword:`break`.  Of course, other ways of ending the
+loop early, such as a :keyword:`return` or a raised exception, will also skip
+execution of the :keyword:`else` clause.
 
 This is exemplified in the following :keyword:`!for` loop,
 which searches for prime numbers::

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]

Reply via email to