On Mon, May 10, 2021 at 12:49 PM Guido van Rossum <gu...@python.org> wrote:
>
> On Sun, May 9, 2021 at 5:08 PM Chris Angelico <ros...@gmail.com> wrote:
>>
>> On Mon, May 10, 2021 at 9:57 AM Steven D'Aprano <st...@pearwood.info> wrote:
>> >
>> > On Sun, May 09, 2021 at 04:45:55PM -0000, Thomas Grainger wrote:
>> >
>> > > now that python2.7 is EOL, it might be worth resurrecting this syntax
>> > [...]
>> > > except E1, E2, E3 as e:
>> >
>> > What advantages will this new syntax bring us?
>> >
>> > Will it allow us to do things that we can't currently do?
>> >
>> > When would you use it in preference to the existing syntax? By this I
>> > mean both under what circumstances, and at what time (tomorrow? in a
>> > year? in ten years?).
>> >
>> > Is there an aim beyond saving two characters?
>> >
>>
>> It would remove a level of frustration. I've watched a lot of novice
>> programmers, and some intermediate programmers, run into a source of
>> (now completely unnecessary) pain that changing this:
>>
>> except ValueError:
>>
>> into this:
>>
>> except ValueError, TypeError:
>>
>> doesn't work. Yes, it's a quick SyntaxError, but the editor won't show
>> it up (since most editors are Python 2 compatible, and wouldn't be
>> checking this level of syntax anyway), so there's X amount of time
>> spent coding, then go to run the thing, and it won't work the way they
>> expect it to.
>
>
> We've had arguments like this before, and we've usually taken the position 
> that we shouldn't compromise the language to cater to imperfect tools. 
> Editors that are Python-aware should just catch up with Python 3 syntax. 
> Editors that don't check this level of syntax definitely shouldn't be used as 
> motivation at all.
>
> (I just tried this in the latest VS Code Insiders edition, and the Python 
> support does catch this.)
>
> Also, I wonder what made those users think to try that? Maybe they read a 
> tutorial or  StackOverflow issue suggesting the Python 2 syntax?

It's the obvious way to extend from a single exception name to two.
Think of it *without* the "as" clause and it becomes less clear that
the parentheses are necessary.

> Someone else (Steven?) already pointed out in this thread that there are 
> other places where 'as <target>' or 'as <identifier>' as used, the relative 
> precedence of commas and 'as' is different than the proposal here:
>
>> It's true that adding "as e" makes it read oddly, but that's the only
>> real point against it - other than a question of "when".
>
>
> I think never is a perfectly fine answer.
>

I think "because of the possibility of the as clause, it's not worth
doing this" is a perfectly fine answer too. It would be nice if
"except TypeError, ValueError:" could be made valid, but that may not
be worth the hassle.

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

Reply via email to