Python 3.11 ~upd~ Official

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.

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

import tomllib with open("config.toml", "rb") as f: config = tomllib.load(f) print(config["tool"]["poetry"]["name"]) Python 3

ExceptionGroup and except* .

# Python 3.11+ from asyncio import gather, sleep async def risky_task(name, fail): await sleep(0.1) if fail: raise ValueError(f"name failed") return name sleep async def risky_task(name