[Python-Dev] Re: PEP 622 version 2 (Structural Pattern Matching)

2020年8月05日 03:39:38 -0700

Welcome to python-dev, Rik! Of course you can email to this list.
On 30/07/2020 14:30, Rik de Kort via Python-Dev wrote:
I think adding the Walrus operator is trying to solve a problem that doesn't exist. Compare the example from the PEP:
  [snip]
 case (x, y, z):
[snip]
To the one without:
[snip]
 case (x := _, y := _, z := _):
It's a lot more typing, it's a lot more ugly, and I'd argue it's not any more explicit than the earlier one.
The debate is still going on as to whether "capture" variables should be marked, and if so whether with the walrus operator or in some other way, and "var := _" wouldn't be my personal preference. However,
 case (x := _, y := _, z := _):
*is* more explicit, because it explicitly says that x, y and z are variables that should capture (i.e. be bound to) whatever values are found. Contrast this with say
 case (x := _, y := _, z):
which says that z contains a value to be *matched*, and if such a match is 
found, x and y should capture the relevant values.
Best wishes
Rob Cliffe
_______________________________________________
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/BBS23YZIX2HVFMF67F3QRU3R3TWNB75S/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to