On Sat, Oct 31, 2020 at 09:05:43PM -0700, Guido van Rossum wrote:
Hm, for PEP 622/634 we looked at this and ended up making it so that this is the default -- you only have to write ``` {'spam': spam, 'eggs': eggs} = mapping ``` and any extra keys are ignored. This is because for the common use case here we want to ignore extra keys, not insist there aren't any.
Regardless of which is commoner than the other, what about the use-case where you do want to insist that the mapping is an exact match? Having matched the two keys how do I say that there are no more keys? In the case of the `match` statement, I think that "ignore extra keys" by default is risky. Consider something like this: match mapping: case {'spam': spam}: print(spam) case {'spam': spam, 'eggs': eggs}: print('this will never be called') There's no case that will match the second that isn't already captured by the first. -- Steve