This was proposed in 2014 and was rejected: https://www.python.org/dev/peps/pep-0463/
That being said, I would support such a thing being added to the language. My preferred syntax would be `try expression except ExceptionType [as e] with alternative`, or even `expression except ExceptionType [as e] with alternative`. Steele On Tue, Jun 1, 2021 at 4:11 PM Shreyan Avigyan < [email protected]> wrote: > Python has support for conditional statement, list comprehensions, dict > comprehensions, etc. So we can write these in mere one or two lines. But > for try-except it's not possible to write it one or two lines. Many a > times, we have one stmt that we want to check and if it raises error then > do nothing or just execute one stmt. This idea proposes to add a way to > write try-except for one stmt in one line. > > Thanking you, > > With Regards > _______________________________________________ > 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/T7UKDECCKNXPWIJ6VLCDGAVSXRJQVZ7W/ > Code of Conduct: http://python.org/psf/codeofconduct/ >
_______________________________________________ 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/DK45GOPP2BJEGQQWS63O6EKIQITEPDZM/ Code of Conduct: http://python.org/psf/codeofconduct/
