TIL: Inline dependencies in Python scripts

When sharing a Python script as a gist, you’d typically include a requirements.txt or a pyproject.toml with uv.lock. Multiple files for one script. Turns out there’s a cleaner way. PEP 723 lets you embed dependencies and Python version requirements directly in the script: # /// script # requires-python = ">=3.11" # dependencies = [ # "requests", # "rich", # ] # /// import requests from rich import print response = requests.get("https://api.github.com/zen") print(f"[bold green]{response.text}[/bold green]") Run it with uv: ...

January 13, 2026 · 1 min · Deepankar Mahapatro