
On 13/07/2020 15:33, Guido van Rossum wrote:
On Mon, Jul 13, 2020 at 04:35 Rhodri James <rhodri@kynesim.co.uk> wrote:
[Re: forbidding **_ in mapping patterns]
I’d rather not. And the argument about disallowing obviously redundant syntax seems weak. My worry about allowing this is that it’ll be cargo culled and we’ll see it used not for emphasis (of what? The obvious?) but because people think it’s needed. And that’s just clutter.
Fair enough. I'd likely use it to remind myself of cases when there will always be more keys in the mapping, but a comment will do just as well.
Can I use pattern matching to pull byte strings apart? I thought I could, but trying it out in the playground didn't work at all. :-(
It’s explicitly forbidden by the PEP, because we don’t want str or bytes to accidentally match sequence patterns. You could do ‘match list(b):’ if you really wanted to, but I think there are better tools for parsing bytes or strings.
:-( As an embedded engineer, pulling apart network protocols was the first use I thought of for matching. Ah well. -- Rhodri James *-* Kynesim Ltd