On Jun 23, 2020, at 12:27, Rob Cliffe via Python-Dev <python-dev@python.org> 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