> On 6 Oct 2021, at 16:01, Petr Viktorin <encu...@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.

- Ł

Attachment: signature.asc
Description: Message signed with OpenPGP

_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/BL6PSZZCGLDQSMHTZTWRCP6G6KD6OK3K/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to