I’m puzzled by
except* in PEP 654; the overarching purpose of this new syntax seems to be to place a condition on whether or not to catch an exception, but the condition is immensely special-case. It’s strange to see syntax being added to the language that is so narrow in scope that I have my doubts about whether I’m ever going to use it, even once.
So how about a general exception conditioning mechanism instead? E.g., adapting a random PEP 654 example:
try: low_level_os_operation() except ExceptionGroup as eg if (oserr := eg.find(OSError)): for e in oserr.exceptions: print(type(e).__name__)
This seems like an obvious idea, so I searched the forum and indeed found this post by Nathaniel J. Smith, which I’d probably seen before, so I’m not taking credit for the idea. Please read Nathaniel’s post.