Author terry.reedy
Recipients brandtbucher, docs@python, gvanrossum, terry.reedy
Date 2021-05-04.02:04:37
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1620093878.28.0.805814541074.issue44025@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2021-05-04 02:04:38terry.reedysetrecipients: + terry.reedy, gvanrossum, docs@python, brandtbucher
2021-05-04 02:04:38terry.reedysetmessageid: <1620093878.28.0.805814541074.issue44025@roundup.psfhosted.org>
2021-05-04 02:04:38terry.reedylinkissue44025 messages
2021-05-04 02:04:37terry.reedycreate