summaryrefslogtreecommitdiffstats
path: root/Doc/reference
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2021-05-04 11:36:50 (GMT)
committerGitHub <noreply@github.com>2021-05-04 11:36:50 (GMT)
commitae4f8574993c85f9dc6fe60e6a25d65f688705e6 (patch)
tree4cf3ded9a3dfee3ee41d7d3d48e85123eaf3f59f /Doc/reference
parentaa0ce1615f48742591535579d81c0ada1083a33e (diff)
downloadcpython-ae4f8574993c85f9dc6fe60e6a25d65f688705e6.zip
cpython-ae4f8574993c85f9dc6fe60e6a25d65f688705e6.tar.gz
cpython-ae4f8574993c85f9dc6fe60e6a25d65f688705e6.tar.bz2
bpo-44025: Clarify when '_' is a keyword. (GH-25873)
In match statements, in case patterns and nowhere else. Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com> (cherry picked from commit 3b200b2aa648fcc8a2673871807c1463afe00195) Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
Diffstat (limited to 'Doc/reference')
-rw-r--r--Doc/reference/compound_stmts.rst6
1 files changed, 4 insertions, 2 deletions
diff --git a/Doc/reference/compound_stmts.rst b/Doc/reference/compound_stmts.rst
index 96bd9b0..77400a8 100644
--- a/Doc/reference/compound_stmts.rst
+++ b/Doc/reference/compound_stmts.rst
@@ -797,7 +797,7 @@ Syntax:
capture_pattern: !'_' NAME
A single underscore ``_`` is not a capture pattern (this is what ``!'_'``
-expresses). And is instead treated as a :token:`wildcard_pattern`.
+expresses). It is instead treated as a :token:`wildcard_pattern`.
In a given pattern, a given name can only be bound once. E.g.
``case x, x: ...`` is invalid while ``case [x] | x: ...`` is allowed.
@@ -820,7 +820,9 @@ and binds no name. Syntax:
.. productionlist:: python-grammar
wildcard_pattern: '_'
-``_`` is a :ref:`soft keyword <soft-keywords>`.
+``_`` is a :ref:`soft keyword <soft-keywords>` within any pattern,
+but only within patterns. It is an identifier, as usual, even within
+``match`` headers, ``guards``, and ``case`` blocks.
In simple terms, ``_`` will always succeed.