https://github.com/python/cpython/commit/1b5db5adfec10d90cf5c7abd6817452be4f0b909
commit: 1b5db5adfec10d90cf5c7abd6817452be4f0b909
branch: main
author: Tshepang Mbambo <[email protected]>
committer: brandtbucher <[email protected]>
date: 2025-03-05T14:59:47-08:00
summary:
GH-130153: Reword the wildcard matching part of the tutorial (GH-129954)
files:
M Doc/tutorial/controlflow.rst
diff --git a/Doc/tutorial/controlflow.rst b/Doc/tutorial/controlflow.rst
index 8261bbdbfb7a01..95939242fb7d44 100644
--- a/Doc/tutorial/controlflow.rst
+++ b/Doc/tutorial/controlflow.rst
@@ -289,7 +289,8 @@ similar to a switch statement in C, Java or JavaScript (and
many
other languages), but it's more similar to pattern matching in
languages like Rust or Haskell. Only the first pattern that matches
gets executed and it can also extract components (sequence elements
-or object attributes) from the value into variables.
+or object attributes) from the value into variables. If no case matches,
+none of the branches is executed.
The simplest form compares a subject value against one or more literals::
@@ -305,7 +306,7 @@ The simplest form compares a subject value against one or
more literals::
return "Something's wrong with the internet"
Note the last block: the "variable name" ``_`` acts as a *wildcard* and
-never fails to match. If no case matches, none of the branches is executed.
+never fails to match.
You can combine several literals in a single pattern using ``|`` ("or")::
_______________________________________________
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]