On Mon, Aug 17, 2020 at 3:37 AM Mark Shannon <m...@hotpy.org> wrote: > > > On 16/08/2020 9:41 pm, Guido van Rossum wrote: > > On Sun, Aug 16, 2020 at 12:37 PM Jean Abou Samra <j...@abou-samra.fr > > <mailto:j...@abou-samra.fr>> wrote: > > Also, I see potential for a caveat: > > > > match number: > > case int: # missing parentheses! > > ... > > case float: > > ... > > case Fraction: > > ... > > > > In this case, if I understand the specification correctly, the first > > case will always match, right? Maybe the interpreter could throw a > > SyntaxWarning when a bare capture pattern (without a guard) is used > > as a pattern in any case clause other than the last one? As far as I > > understand, this could possibly prevent many of the mistakes in > > load/store that people have been rightfully complaining about so > > far. It's merely a stronger measure than letting static checkers do > > the work (since we don't all use these tools). > > > > > > The reference implementation in fact does issue a SyntaxWarning for this > > case. > > Shouldn't that detail be in the PEP? >
Good point. I have added a note about this in the section on static checkers, under "Note about constants": https://github.com/python/peps/commit/6a7d6b831f9af7db651269231c77037aff6bad8f (I should mention that the PEP authors are also grateful for your observation about what users expect for `case True`, and we are now discussing this in our issue tracker at https://github.com/gvanrossum/patma/issues/139. We're also discussing Jean's point about `as` vs. `:=` in issue 140.) -- --Guido van Rossum (python.org/~guido) *Pronouns: he/him **(why is my pronoun here?)* <http://feministing.com/2015/02/03/how-using-they-as-a-singular-pronoun-can-change-the-world/>
_______________________________________________ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-le...@python.org https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/KQD4D3SMFDJZKUEUWEWKQIFO7WDRDNHX/ Code of Conduct: http://python.org/psf/codeofconduct/