Nov. 5, 2020
12:06 a.m.
On Tue., 3 Nov. 2020, 8:07 am Ethan Furman, <ethan@stoneleaf.us> wrote:
On 11/2/20 1:52 PM, Glenn Linderman wrote:
On 11/2/2020 1:42 PM, Guido van Rossum wrote:
But we feel that `case x, x` can easily be misunderstood as "a tuple of two equal values"
So what _is_ the syntax for "a tuple of two equal values" ?
case x, ?x: # comes to mind (not that it is in the PEP :))
Using a guard statement:
case x, y if x == y
This example made me realise that I need to add test cases for "case x, ==x:" and "case x, is x:" to PEP 642's reference implementation (and text to the PEP pointing out that explicit constraints can help address the pattern back-reference problem). Cheers, Nick.