On Sat, Nov 14, 2020 at 10:17:34PM -0800, Guido van Rossum wrote:

> It’s a usability issue; mappings are used quite differently than sequences.
> Compare to class patterns rather than sequence patterns.

I'm keeping an open mind on this question, but I think David 
is right to 
raise it. I think that most people are going to see this as 
dict 
matching as "ignoring errors by default" and going against the Zen of 
Python, and I expect that we'll be answering questions about it for 
years to come.

"Why did my match statement match the wrong case?"

Naively, I too would expect that dicts should only match if the keys 
match with no left overs, and I would like to see the choice to ignore 
left overs justified in the PEP.

It would be good if the PEP gave a survey of the practical experience of 
other languages with pattern matching:

- are there languages which require an exact match, with no left over 
  keys? what issues, if any, do users have with that choice?

- which languages ignore extra keys? do users of those languages 
  consider this feature a bug, a wart, or a feature?


-- 
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/OVJKX3SY525EO62JBPSW2REZ66CK5RBU/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to