On Fri., 13 Nov. 2020, 4:01 am Guido van Rossum, <gu...@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 <
> devel2...@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-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/RQPUV7PABLBNYJ7FI7QYCS6TKJ4H2Q2A/
>> 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-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/DPDHLPKAG3ATDH47NZNWGPK2FKBCY7WR/
> Code of Conduct: http://python.org/psf/codeofconduct/
>
_______________________________________________
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/4MY4YSRZZIYBUTETYPF3EAPGVWC26YYF/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to