[Python-Dev] Re: PEP 622: Structural Pattern Matching

2020年6月24日 08:17:57 -0700

On Tue, Jun 23, 2020 at 10:10 AM MRAB <[email protected]> wrote:
> Why are:
>
> case ._:
>
> not OK?
>
> In this:
>
> case .BLACK:
> ...
> case BLACK:
> ...
>
> the first matches the value against 'BLACK' and the second succeeds and
> binds the value to 'BLACK'.
>
> Replacing 'BLACK' with '_':
>
> case ._:
> ...
> case _:
> ...
>
> I'd expect something similar, except for the binding part.
>
> I think the same could be said for:
>
> case Color.BLACK:
>
> and:
>
> case _.BLACK:
>
The PEP authors discussed this last night and (with a simple majority) we
agreed that this restriction isn't all that important, so we're dropping it.
https://github.com/python/peps/commit/410ba6dd4841dc445ce8e0cd3e63ade2fa92ddc4
(We're considering other feedback carefully, but most of it require more
deliberation.)
-- 
--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 -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/VJIEPJ7LBUQPBQN2CI6TOZNKJFE3WE7B/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to