
On Fri., 13 Nov. 2020, 4:01 am Guido van Rossum, <guido@python.org> wrote:
The position of PEP 622/634/535/636 authors is clear: we see this as a necessary feature to support using enums (e.g. Color.RED) or constants defined in other modules (e.g. re.I) when simple switch functionality is being migrated from literals (e.g. case 404) to named constants (e.g. case HTTPStatus.NOT_FOUND). Bothering users with the technicality of needing to use '==' here is a big usability hit.
Right, this was a part of Steven D'Aprano's counterproposal that I found compelling, so PEP 642 now keeps the inferred equality constraints for the patterns that are unambiguous in context. The "==" is only required when the expression would otherwise be interpreted as a capture pattern, or wouldn't be allowed in a pattern at all. Cheers, Nick.
On Thu, Nov 12, 2020 at 7:38 AM Baptiste Carvello < devel2020@baptiste-carvello.net> wrote:
Hi,
Le 08/11/2020 à 07:47, Nick Coghlan a écrit :
Hi folks,
I have updated PEP 642 significantly based on the feedback received over the past week.
[...] a change that I feel is insufficiently discussed is the choice to have "attr_constraint" as an inferred constraint. I can think of arguments to defer it for now at least:
* it is a one way door (if dotted names are made a constraint pattern now, they can't become a capture pattern later);
* it makes a difference from assignment target syntax, where you can assign to a dotted name;
* the shorthand notation is less valuable than for literals, as dotted names are verbose already, 3 more characters make little difference;
* the user has no explicit syntax to override the inferred semantics.
I feel like some discussion of this choice in the PEP would make sense.
Cheers, Baptiste _______________________________________________ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-leave@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/RQPUV7PA... Code of Conduct: http://python.org/psf/codeofconduct/
-- --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-c...> _______________________________________________ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-leave@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/DPDHLPKA... Code of Conduct: http://python.org/psf/codeofconduct/