On Wed, Jun 24, 2020 at 5:23 AM Eric Wieser <wieser.eric+nu...@gmail.com>
wrote:

> In regards to
> https://www.python.org/dev/peps/pep-0622/#alternatives-for-constant-value-pattern,
> was this alternative considered?
> ```
> match obj:
>     case SomeClass(field := _):  # is this already allowed by the PEP?
>         pass
>     case some_constant:  # my proposal: do not require `.some_constant`
> here
>         pass
>     case (other := _):  # is this already allowed by the PEP? If so, do we
> need the extra `case other:` spelling?
>         print(other)
> ```
>
> It seems like `:=` already provides all the necessary syntax for
> distinguishing bindings from constants, admittedly at the cost of 6
> characters per binding (eg `Point(x := _, y := _)`) - so introducing
> additional syntax seems unnecessary.
>

In languages that have pattern matching, it is the primary way to extract
pieces of a compound data structure into individual variables. For the use
cases where match would be a good fit in Python, the same will be true. So
using your proposed syntax here is too verbose to consider.


> If this was considered but rejected for verbosity concerns, it would be
> nice to see it mentioned in the rejected alternatives section.
>

We can't discuss every single idea in that section. I don't think anyone
else has proposed this, so I don't think it needs to be discussed for
posterity. There are plenty of better ideas in this thread that deserve a
mention there.

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

Reply via email to