On 2020-06-23 22:53, Emily Bowman wrote:
On Tue, Jun 23, 2020 at 2:10 PM MRAB <firstname.lastname@example.org mailto:email@example.com> wrote:
I think that's done for consistency. '_' is a wildcard and you can have: case (_, _): to match any 2-tuple, so: case _: would match any value, and can thus already serve as the default. I wouldn't object to 'else', though.
Can you have case (x,x): ? I haven't tried the implementation, but it's not addressed in the PEP that I see, and if that's legal, then _ is effectively just a style choice, rather than a functional one, and there's no reason it shouldn't also be a named match.
You cannot bind to the same name twice, so "case (x,x):"is an error.
+1 for including "else:" for consistency even if that's just a shim for "case _:"