[Python-Dev] Re: PEP 622: Structural Pattern Matching

2020年6月24日 18:55:24 -0700

On 2020年06月24日 23:14, Ethan Furman wrote:
On 06/24/2020 01:49 PM, Tim Peters wrote:
I too thought "why not else:?" at first. But "case _:" covers it in
the one obvious way after grasping how general wildcard matches are.
"case _:" is easy to miss -- I missed it several times reading through the PEP.
Introducing "else:" too would be adding a wart (redundancy) just to
stop shallow-first-impression whining.
Huh. I would consider "case _:" to be the wart, especially since "case default:" or "case 
anything:" or "case i_dont_care:" all do basically the same thing (although they bind to the given name, 
while _ does not bind to anything, but of what practical importance is that?) .[snip]
The point of '_' is that it can be used any number of times in a pattern:
 case (_, _):
This is not allowed:
 case (x, x):
When a pattern matches, binding occurs, and why bind to a name when you don't need/want the value?
_______________________________________________
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/7LT5QOEMLVUPT6TNKLIWCN3I4F3XHMTD/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to