> (2) For the form of the assignment target, I think an analogy with the
> reception of function arguments could also be considered.
I think so -- maybe only because it's new, but folks are certainly far more familiar with **kwargs than pattern matching.
> For an assignment without **rest, the
> assignment source can just be sliced beforehand.
Yeah, that's something that could be considered, but it's worth noting
that PEP 622 says that match syntax doesn't demand {**_} for mapping
patterns.
Extra keys in the subject are ignored even if **rest is not present.
This is different from sequence pattern, where extra items will cause
a match to fail. But mappings are actually different from sequences:
they have natural structural sub-typing behavior, i.e., passing a
dictionary with extra keys somewhere will likely just work.
Except in unpacking in a function call -- which I this "feels" more like to me.
-CHB
-- Christopher Barker, PhD (Chris)
Python Language Consulting
- Teaching
- Scientific Software Development
- Desktop GUI and Web Development
- wxPython, numpy, scipy, Cython