Throwaway Python
Language models adept at Python offer throwaway code one might want to execute and forget, and it's not unusual for these language models to assume access to the wider Python ecosystem.
As of devenv 1.6, Nix-adjacent types like me can create an ephemeral shell with Python and uv like so:
devenv shell \
--option languages.python.enable:bool true \
--option languages.python.uv.enable:bool true \
zsh
And thanks to inline script metadata we can serve our language-model by providing the dependencies it has encoded in its multitudinal dimensions.
# /// script
# dependencies = [
# "requests<3",
# "rich",
# ]
# ///
import requests
from rich.pretty import pprint
resp = requests.get("https://peps.python.org/api/peps.json")
data = resp.json()
pprint([(k, v["title"]) for k, v in data.items()][:10])
And with all of this we’re able to run our Python code like so:
uv run <script>