[New-bugs-announce] [issue44025] Match doc: Clarify '_' as a soft keyword
Terry J. Reedy
report at bugs.python.org
Mon May 3 22:04:38 EDT 2021
New submission from Terry J. Reedy <tjreedy at udel.edu>:
In #44010, we are trying, as best as is possible with comprehensible REs, to identify in which circumstances occurrences of 'match', 'case' and '_' are keywords, and should be marked as such. I was initially unsure and even wrong about '_'.
1. Capture Patterns: I was confused by 'And is instead...'. 'It is instead ...', where 'it' refers to '_', is clearer to me.
2. Wildcard Patterns: "'_' is a soft keyword" just says it sometimes is and sometimes is not, but not when, or rather, where. After experiments like this (using the new IDLE 'copy with prompts' option ;-):
>>> _ = 'a'
>>> match [_, 'b']:
... case [capture, _] if _ == 'a':
... print(capture, _)
...
a a
I added (in PR to come, with markup that might be improved)
"within any pattern, but only within patterns. It is an identifier, as usual, even within ``match`` headers, ``guards``, and ``case blocks``.
Please consider also adding an example like the above.
----------
assignee: docs at python
components: Documentation
messages: 392848
nosy: brandtbucher, docs at python, gvanrossum, terry.reedy
priority: normal
severity: normal
stage: patch review
status: open
title: Match doc: Clarify '_' as a soft keyword
type: behavior
versions: Python 3.10, Python 3.11
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue44025>
_______________________________________
More information about the New-bugs-announce
mailing list