Questions tagged [python]
Post a PromptPrompts producing Python programs.
20 prompts
9votes
1answers
1.7kviews
Forcing the model to write the failing test first instead of the impl
I do strict TDD and I wanted the model to do it with me, not for me. Default behavior with GPT is: ask for a feature, get the implementation plus some tests it wrote to match the code it just wrote. T
8votes
1answers
1.5kviews
Getting the model to propose property-based tests, not three happy-path cases
Ask any model for tests and you get three example-based cases: a normal input, an empty input, maybe a null. Fine, but they miss the weird stuff. I wanted property-based tests that assert invariants a
8votes
1answers
894views
Turning a messy matplotlib notebook into one reproducible plotting script
I had a research notebook with 40 cells of exploratory plots, half of them relying on variables defined three cells up and a global rcParams tweak that only worked if you ran things in order. Sharing
7votes
1answers
1.1kviews
What's the best prompt structure for getting Python scripts with proper error handling?
Every generated Python script I get is happy-path only: no retries, bare excepts, crashes on the first weird input. I've been experimenting with a checklist-style prompt suffix that forces defensive c
5votes
0answers
969views
Splitting a 600-line god function into pure units without behavior drift
The worst function in our codebase does input parsing, three network calls, retry logic, formatting, and logging in one 600-line block. I wanted GPT to carve it into small pure functions plus a thin o