[issue44025] Match doc: Clarify '_' as a soft keyword

New submission from Terry J. Reedy <tjreedy@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@python components: Documentation messages: 392848 nosy: brandtbucher, docs@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@bugs.python.org> <https://bugs.python.org/issue44025> _______________________________________

Change by Terry J. Reedy <tjreedy@udel.edu>: ---------- keywords: +patch pull_requests: +24552 pull_request: https://github.com/python/cpython/pull/25873 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue44025> _______________________________________

Change by miss-islington <mariatta.wijaya+miss-islington@gmail.com>: ---------- nosy: +miss-islington nosy_count: 4.0 -> 5.0 pull_requests: +24562 pull_request: https://github.com/python/cpython/pull/25888 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue44025> _______________________________________

miss-islington <mariatta.wijaya+miss-islington@gmail.com> added the comment: New changeset ae4f8574993c85f9dc6fe60e6a25d65f688705e6 by Miss Islington (bot) in branch '3.10': bpo-44025: Clarify when '_' is a keyword. (GH-25873) https://github.com/python/cpython/commit/ae4f8574993c85f9dc6fe60e6a25d65f688... ---------- _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue44025> _______________________________________

Terry J. Reedy <tjreedy@udel.edu> added the comment: bedevere-bot malfunctioned. Lukasz merged PR 25873 into main, and I verified the change on the main branch. But the PR is listed above as closed, not merged, and commit 3b200b2aa648fcc8a2673871807c1463afe00195 is not listed. ---------- nosy: +Mariatta, lukasz.langa _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue44025> _______________________________________
participants (2)
-
miss-islington
-
Terry J. Reedy