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

2020年6月24日 12:32:25 -0700

On 2020年6月24日 at 19:49, M.-A. Lemburg <[email protected]> wrote:
> match something:
> case 0 | 1 | 2 | _:
> print("Small number or something else")
> case [] | [_]:
> print("A short sequence")
> case _:
> print("Not sure what this is")
> case str() | bytes():
> print("Something string-like")
>
Because the semantics is "first matching clause applies", putting
`case _` anywhere but at the end wouldn't work as expected. The `str()
| bytes()` case above would never match.
Paul
_______________________________________________
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/YZOMXXY5XCADTTXBUMDE2KA6PCVCNEJP/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to