On Mon, May 10, 2021 at 9:57 AM Steven D'Aprano <[email protected]> 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. If it weren't for the Python 2 issues, would there be any good reason for demanding parentheses? We don't need them in a for loop: for i, thing in enumerate(stuff): 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". ChrisA _______________________________________________ Python-ideas mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/[email protected]/message/6I7XQYSNUSF76CZQBSYDYVVOXYHDOBER/ Code of Conduct: http://python.org/psf/codeofconduct/
