24 Jun
2020
24 Jun
'20
3:23 a.m.
On Tue, Jun 23, 2020 at 2:10 PM MRAB
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. +1 for including "else:" for consistency even if that's just a shim for "case _:"