Results 6 comments of abetkin

You can probably use assignment expressions too) ```python try: except: if exc := match(group := get_exception(), MyException): print(exc) elif match(group, SecondException): print('second exception') ```

Imho this can't compete with context manager version: ```python try: except: with get_exception() as group: if ex := handle(group, Exception): raise OtherException ``` In the above example `handle` is destructive...

Exactly, then probably only replacing both `if`s with `with` will work. So you can suppress all the exceptions and accumulate them. But yes, you have less flexibility with context managers...

Well, anyway it doesn't look too good. There is a crazy idea how to replace a couple of functions with one: ```python try: except: def handler(ex): if match(MyException, ex): ......