On Sun, Oct 3, 2021 at 11:40 PM Steven D'Aprano <[email protected]> wrote:
> On Sun, Oct 03, 2021 at 11:34:55AM -0700, Guido van Rossum wrote:
>
> > I also think that the bar should be pretty high before we reopen the
> > *syntax* -- the PEP was approved without anyone (neither the SC, nor
> > Nathaniel, nor anyone else) providing any feedback on the use of 'except
> > *'. So I think it's a bit late to be bikeshedding the syntax. This thread
> > was meant to solicit feedback on how to *format* it: does the space go
> > before or after the '*'.
>
> `except* E`, otherwise it looks like unpacking E.
>
I think it's worth noting that the following is already legal:
Python 3.9.7 (tags/v3.9.7:1016ef3, Aug 30 2021, 20:19:38) [MSC v.1929 64
bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> exceptions = (ValueError, TypeError)
>>> try:
... raise TypeError
... except exceptions:
... print("caught")
...
caught
Indeed, when I first learned that you could do this (a few years ago IIRC),
my first thought was to unpack the "exceptions" tuple with a star. It
wasn't until I tried that and got a SyntaxError that I tried it the way
shown here and it worked.
Allowing `except *E` for this new feature would take that
helpful-to-a-beginner SyntaxError and turn it into a subtle and unhelpful
bug.
Therefore my vote is for requiring `except* E` and keeping `except *E` as a
SyntaxError.
_______________________________________________
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/2TBZZSMZXNYFJNPLIESFNFDNDX5K6A5X/
Code of Conduct: http://python.org/psf/codeofconduct/