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

2020年6月23日 14:41:32 -0700

On Wed, Jun 24, 2020 at 2:04 AM Guido van Rossum <[email protected]> wrote:
> def http_error(status):
> match status:
> case 404:
> return "Not found"
> case 418:
> return "I'm a teapot"
> case _:
> return "Something else"
>
> Note the last block: the "variable name" `_` acts as a *wildcard* and
> never fails to match.
I can't find it among the rejected alternatives, but was it considered
to use "..." as the wildcard, rather than "_"? It carries similar
meaning but its special case of "this will never be bound" is simply
preventing an error, rather than making one otherwise-valid name
special.
> Raw strings and byte strings are supported. F-strings are not allowed (since 
> in general they are not really literals).
It won't come up often, but are triple-quoted strings allowed?
ChrisA
_______________________________________________
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/OH4UXRFTPXG2JQFW44GZ2E2FGHYAC4LK/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to