Python Inline Scripts

Guide for running inline Python scripts with uv. This should be used when the user says "use inline python Use when this capability is needed.

tomevault-io 565e563 2 files · 1.4 KB Updated

File contents

Python Inline Scripts with uv

IMPORTANT

  • NEVER add stdlib modules like json, os, re, etc. to dependencies OR THE SCRIPT WILL FAIL
  • ALWAYS assume Python 3.12+

Example

uv run --no-project -q --script - < <(cat <<'EOF'
# /// script
# # ONLY add dependencies array if you need PyPi packages
# dependencies = [
#   "httpx"
# ]
# requires-python = ">=3.12"
# ///

import httpx
print(httpx.get("https://api.github.com/zen").text)
EOF
)

Converted and distributed by TomeVault — claim your Tome and manage your conversions.

tomevault-io/skills-registry/tree/main/jahands--prompts--python-inline-scripts commit 565e5634dd

Frequently asked questions

npx skillmds@latest add tomevault-io/python-inline-scripts