
Yeah, my mental model got the better of me there. I conceptualize try/except as deferring subsequent reraises in the try block, so in that case the "catch all --> do nothing ( --> defer reraise)" and "catch nothing (--> defer reraise)" cases were equivalent. But the way I wrote it was confusing because it sounds like I was implying it just passed, especially because catching the exception requires a manual reraise and the implicit case does not. Hopefully that makes sense? And yes, I think I was narrowing the case that was originally presented to just allowing an omitted except following the behavior you said. Either way, sorry, to drag this out. I'm not particularly concerned about the current setup because, like you said, just adding an except/raise isn't hard and only two lines. Also, I do actually put more weight on the linguistic semantics than my previous messages suggested: try/else linguistically strikes me as meaning more-or-less the same as try/except—the else provides the opposite condition with respect to what's excepted, not what's being tried. And I certainly do *not* advocate for adding or renaming a keyword. On Tue, Aug 1, 2023 at 5:15 PM Chris Angelico <rosuav@gmail.com> wrote:
On Wed, 2 Aug 2023 at 08:22, Mitch <mitchell.negus.57@gmail.com> wrote:
If `except` is omitted, then catch the generic exception and do nothing
and exit.
Not sure what you mean here. If you have a try-finally with no except clause, no exceptions will be caught; the try will be run, then the finally, and then you'll see any exception from the try block.
Perhaps what you're intending is for an omitted except clause to behave like "except: raise"? Because that would probably have most of the effect of the proposed "try-else", without a dangling else.
And I'd still like to see an actual real-world (or "near-real-world") example that would benefit from this. Would adding "except: raise" be a problem?
ChrisA _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-leave@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/OK5LMB... Code of Conduct: http://python.org/psf/codeofconduct/