Python 3.11 adds tomllib to the standard library for reading TOML files.
import tomllib with open("config.toml", "rb") as f: config = tomllib.load(f) print(config["tool"]["poetry"]["name"]) python 3.11
Before 3.11, if you ran multiple tasks and two failed with different errors, Python would raise the first exception and swallow the second. You would lose debugging information. Python 3
ExceptionGroup and except* .
# Python 3.10 Traceback (most recent call last): File "calc.py", line 2, in <module> result = 100 / (50 - 50) ZeroDivisionError: division by zero Traceback (most recent call last): File "calc.py", line 2, in <module> result = 100 / (50 - 50) ~~~~^~~~~~~~~~~~ ZeroDivisionError: division by zero 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