Find Related products on Amazon

Shop on Amazon

Self-contained Python scripts with uv

Published on: 2025-05-23 08:22:58

Self-contained Python scripts with uv TLDR You can add uv into the shebang line for a Python script to make it a self-contained executable. I am working on a Go project to better learn the language. It's a simple API backed by a postgres database. When I need to test out an endpoint, I prefer to use the httpx python package inside an ipython REPL over making curl requests. It's nice to be able to introspect responses and easily package payloads with dicts instead of writing out JSON. Anyway, I decided to write a script to upsert some user data so that I can beat on my /users endpoint. My jam_users.py script looks like this: import httpx import IPython from loguru import logger users = [ dict ( name = "The Dude" , email = "[email protected]" , password = "thedudeabides" ), dict ( name = "Walter Sobchak" , email = "[email protected]" , password = "vietnamvet" ), dict ( name = "Donnie" , email = "[email protected]" , password = "iamthewalrus" ), dict ( name = "Maude" ... Read full article.