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

2020年6月23日 12:55:02 -0700

On Jun 23, 2020, at 12:27, Rob Cliffe via Python-Dev <[email protected]> 
wrote:
> 
> On 23/06/2020 17:01, Guido van Rossum wrote:
>> 
>> You can combine several literals in a single pattern using `|` ("or"):
>> 
>> ```py
>> case 401|403|404:
>> return "Not allowed"
> The PEP is great, but this strikes me as horribly confusing, given that 
> 401|403|404 is already legal syntax.
> IIUC any legal expression can come between `case` and `:`, but expressions 
> that contain `|` at their outermost level are interpreted differently than 
> from in other contexts.
> Presumably adding parentheses:
> case (401|403|404):
> would make it equivalent to
> case 407:
> 
> Is a separator (other than whitespace) actually needed? Can the parser cope 
> with
> case 401 403 404:
Maybe the PEP could support this syntax:
 case in 401, 403, 404:
That seems like it would be both unambiguous and semantically obvious.
Cheers,
-Barry

Attachment: signature.asc
Description: Message signed with OpenPGP

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

Reply via email to