On 6 Oct 2021, at 16:01, Petr Viktorin <encukou@gmail.com> wrote:
What about this:
group = (KeyboardInterrupt, MemoryError) other_group = (KeyError, IndexError)
try: ... except group + other_group as error: ...
Haha, let's see if we can write a Mersienne twister all inside an except statement 👨🏻🔬 Joking aside, since we allow any expression after 'except' 'group' then this is indeed ambiguous. In theory! In practice, however, PEG is satisfied with the first rule that matches entirely, so this is a matter of choosing correct precedence. In this case, it seems it would make sense for "old-style" except to come first because your (convoluted! 🤠) example is potentially useful, whereas "except +TimeoutError:" is pure nonsense. I will prototype a PR for this just so we can play with it. - Ł