←back to thread

740 points chirau | 1 comments | | HN request time: 1.004s | source
Show context
leonheld ◴[] No.44358181[source]
I adore the

  uv add <mydependencies> --script mycoolscript.py
And then shoving

  #!/usr/bin/env -S uv run
on top so I can run Python scripts easily. It's great!
replies(5): >>44358268 #>>44358400 #>>44358419 #>>44358467 #>>44361042 #
simonw ◴[] No.44358467[source]
I built a Claude Project with special instructions just teaching it how to do this, which means it can output full scripts for me with inline dependencies based on a single prompt: https://simonwillison.net/2024/Dec/19/one-shot-python-tools/

Claude 4's training cutoff date is March 2025 though, I just checked and it turns out Claude Sonnet 4 can do this without needing any extra instructions:

  Python script using uv and inline script dependecies
  where I can give it a URL and it scrapes it with httpx
  and beautifulsoup and returns a CSV of all links on
  the page - their URLs and their link text
Here's the output, it did the right thing with regards to those dependencies: https://claude.ai/share/57d5c886-d5d3-4a9b-901f-27a3667a8581
replies(3): >>44358511 #>>44359003 #>>44364481 #
1. varunneal ◴[] No.44358511[source]
claude sonnet typically forgets about uv script syntax in my experience. I usually find myself having to paste in the docs every time. By default it wants to use uv project syntax.