But Point(x as a) already has a meaning in PEP 634; it’s a positional
argument captured in x *and* in a. (Previously spelled as Point(a := x).
The phrase ‘as a’ can be added after any pattern to *also* capture it in
‘a’. More typically used as e.g.‘Pattern(x, y) as p’, which captures the
first two fields in x and y, and the whole Point in p.

On Sat, Nov 14, 2020 at 23:06 Kyle Stanley <aeros...@gmail.com> wrote:

> On Sun, Nov 15, 2020 at 1:56 AM Chris Angelico <ros...@gmail.com> wrote:
>
>> On Sun, Nov 15, 2020 at 4:28 PM Kyle Stanley <aeros...@gmail.com> wrote:
>> >
>> > FWIW, I'd like to add my +1 to usage of "as" for spelling class capture
>> patterns. This is by far the clearest and easiest to read form I've seen
>> thus far, and I suspect that it would be the easiest to explain to users
>> already familiar with usage of "as" from other areas in Python. A new
>> feature being as distinguishable as possible and easy to explain to
>> existing users is very important in my book, and based on the responses, I
>> think that the current "=" form used in PEP 634 for matching class patterns
>> would be substantially more difficult for users to mentally parse and
>> understand compared to "as".
>> >
>> > It's also worth considering new Python users that might have general OO
>> experience but not with robust pattern matching (e.g. Java-heavy
>> backgrounds). I could definitely see "case Point(x=a, y=b):" being confused
>> for instantiation, whereas usage of "as" makes it more clear that something
>> else is happening (hopefully leading them to search around for more info
>> about Python pattern matching).
>> >
>>
>> case Point(x=as a, y=as b):
>>
>> That doesn't read well to me.
>>
>> Or is there some other spelling of 'as' that makes better sense to you?
>>
>
> The post from Nick that I was primarily replying to used the following
> spelling: "case Point(x as a, y as b):".
> _______________________________________________
> 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/JBSWERRHKBYAB7OW5HS3E4FGVTXDTJUP/
> Code of Conduct: http://python.org/psf/codeofconduct/
>
-- 
--Guido (mobile)
_______________________________________________
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/455PZ4Z5MNQQHN5LUGEJWMD2UXGHDFRY/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to