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 _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/MP5FWUVB7RRPYLVHG4KN3YWWAVZSCVP2/ Code of Conduct: http://python.org/psf/codeofconduct/