What about `except case ExceptionGroup[E1 | E2]:`? and use match semantics?
On Sun, 3 Oct 2021, 16:50 Irit Katriel via Python-Dev, <firstname.lastname@example.org> wrote:
We wonder if people have a view on which of the following is clearer/better:1. except *E as e: // except *(E1, E2) as e:
2. except* E as e: // except* (E1, E2) as e:(The difference is in the whitespace around the *).
At the moment * is a separate token so both are allowed, but we could change that (e.g., make except* a token), and in any case we need to settle on a convention that we use in documentation, etc.It is also not too late to opt for a completely different syntax if a better one is suggested.
I don't think X[Y | Z] is close to any syntax match currently allows.
But... I have long thought that the interpreter's exception
matching abilities were underused by the language. Maybe this is
an opportunity for something else interesting, in general?
The problem being, besides the general extra complexity, that the
match statement's variable capture semantics are different to the
`as name` syntax already used by the except statement.