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 < shreyan.avigya...@outlook.com> 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 -- 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/T7UKDECCKNXPWIJ6VLCDGAVSXRJQVZ7W/ > Code of Conduct: http://python.org/psf/codeofconduct/ >
_______________________________________________ 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/DK45GOPP2BJEGQQWS63O6EKIQITEPDZM/ Code of Conduct: http://python.org/psf/codeofconduct/