PEP 723 – Inline script metadata
January 8, 2025
- https://peps.python.org/pep-0723/
- https://packaging.python.org/en/latest/specifications/inline-script-metadata/#inline-script-metadata
- defines a mechanism for embedding metadata within the script itself, and not in an external file
- motivation is that python is often used as a scripting language and would benefit from not having requirements on external files / environments
# /// script
# requires-python = ">=3.11"
# dependencies = [
# "requests<3",
# "rich",
# ]
# ///
import requests
from rich.pretty import pprint
resp = requests.get("[https://peps.python.org/api/peps.json")](https://peps.python.org/api/peps.json"))
data = resp.json()
pprint([(k, v["title"]) for k, v in data.items()][:10])