ExceptionGroup and except* .
async def main(): tasks = [risky_task("A", True), risky_task("B", False), risky_task("C", True)] try: results = await gather( tasks, return_exceptions=False) except ValueError as eg: for exc in eg.exceptions: print(f"Handling: exc") Handling: A failed Handling: C failed python 3.11
Python 3.11 fixes this. When an error occurs, the interpreter now points an arrow ( ^ ) at the specific expression that failed, not just the line number. ExceptionGroup and except*
If you are still on Python 3.8 or 3.9, here is why you should make the jump to 3.11 (or later). The headline feature of Python 3.11 is the result of Microsoft’s "Faster CPython" team, led by Mark Shannon. For years, Python developers accepted the trade-off of slower execution for rapid development speed. Python 3.11 narrowed that gap significantly. If you are still on Python 3