The script ran. That is the weakest signal you have.
You paste a prompt into a chat window. A model returns forty lines of Python. You run it, it draws something, and you move on. That is the moment most review should start, not end.
Real Python published an informal model comparison built around five everyday Python tasks. One task asks a model to draw a python reading a book with the turtle module. The turtle module is a standard-library graphics module that drives a pen around a canvas to draw shapes. The comparison uses the same prompts for each model and no system prompt. The results come from the returned code and replies.
That setup is a reading exercise, not a scoreboard. The useful question is not which model won. It is what the returned code tells you about habits you will live with when you merge it.
What the comparison actually measures
According to the Real Python write-up, the five tasks probe different habits. The snake task runs the script under a virtual display and records every drawing command. The picture is whatever came out, arrow and all. A separate task asks for a small command-line tool, then reads off which language features the model reached for, such as list[str], tomllib, and Path.walk(). The write-up indicates it scores the latest Python version the answer targets, though the excerpt we can see is truncated mid-sentence, so treat that as indicative rather than definitive.
Those are two different kinds of evidence. The turtle task shows you output. The command-line task shows you taste in language features. Neither one tells you whether the code is safe to depend on.
A drawing that appears is a happy path. It says the script executed without an exception on that machine, with that display, at that moment. It says nothing about what happens when a file is missing, a value is empty, or the script runs twice.
Pass one: does it run at all
Start with the boring check. Copy the code into a file. Run it in a clean virtual environment. A virtual environment is an isolated Python installation with its own set of installed packages, so you are not relying on libraries that happen to be on your laptop.
If it fails, read the traceback before you edit anything. The traceback is Python's error report. It names the file, the line, and the exception type. Generated code often fails for mundane reasons: a missing import, a typo in a variable name, or a call to a function that does not exist in your Python version.
That last one matters more than it looks. The Real Python comparison reads off which language features a model uses. If a model writes list[str], tomllib, or Path.walk(), your interpreter has to support each one, and they do not share a minimum version:
list[str]as a runtime annotation needs Python 3.9 or newer.tomllibarrived in Python 3.11.Path.walk()arrived in Python 3.12.
Path.walk() is a newer and less commonly emitted feature, so the version-floor point is strongest for tomllib and list[str]. On an older interpreter, the import or the call fails immediately. A single "it runs" check on your machine does not tell you which of those three floors the code assumes.
Running once is a smoke test. A smoke test is a quick check that the thing starts. It is not a correctness test.
Pass two: the obvious edge case
Every small script has one input that a careless author forgets. Find it before you trust the code.
For a turtle drawing, the edge case is usually not an input at all. It is the environment. Does the script assume a display exists? Does it leave the window open, or close it before you can look? Does it draw off-screen because coordinates were guessed rather than computed?
The Real Python setup runs scripts under a virtual display and records drawing commands. That is a deliberate harness. Your laptop is not that harness.
For a command-line tool, the edge case is the argument. Here is a short, runnable example of the kind of guard I add to generated CLI code before I keep it:
import argparse
import sys
from pathlib import Path
def count_lines(path: Path) -> int | None:
try:
with path.open("r", encoding="utf-8") as handle:
return sum(1 for _ in handle)
except FileNotFoundError:
print(f"error: no such file: {path}", file=sys.stderr)
return None
except UnicodeDecodeError:
print(f"error: not valid UTF-8: {path}", file=sys.stderr)
return None
def main() -> int:
parser = argparse.ArgumentParser(description="Count lines in a text file.")
parser.add_argument("path", type=Path)
args = parser.parse_args()
total = count_lines(args.path)
if total is None:
return 1
print(total)
return 0
if __name__ == "__main__":
raise SystemExit(main())Run it three ways: with a real file, with a path that does not exist, and with a binary file that is not valid UTF-8. The first run proves the happy path. The second and third prove the code fails in a way you can read. Pick the binary file deliberately—use a PNG or a compiled .pyc; a plain ASCII text file renamed .bin will not trigger the UnicodeDecodeError branch at all.
Generated code often skips the second and third cases. It opens the file, reads it, and lets any exception escape as a stack trace. That is not always wrong. But you should choose it, not inherit it.
Pass three: would you maintain it
This is the pass most people skip, and it is the one that costs the most later.
Ask three questions. Is the structure something you could change next month? Are the names honest? Is there hidden state you would have to hold in your head?
A turtle script that is one long block of forward, right, and color calls is fine for a demo. It is painful to adjust. If you want the snake's head to move, you have to find every coordinate that depends on it.
Here is a small, maintainable version of the book-drawing portion, written from scratch to show the structure I'd want. It separates the geometry from the drawing calls:
import turtle
def draw_book(pen: turtle.Turtle, x: float, y: float, width: float, height: float) -> None:
pen.penup()
pen.goto(x, y)
pen.pendown()
for _ in range(2):
pen.forward(width)
pen.right(90)
pen.forward(height)
pen.right(90)
def main() -> None:
screen = turtle.Screen()
screen.title("A python reading a book")
pen = turtle.Turtle()
pen.speed(0)
draw_book(pen, -60, -40, 120, 80)
screen.mainloop()
if __name__ == "__main__":
main()This does not draw a snake. It draws the book frame, and it shows the shape of a maintainable version: one function with named parameters, one entry point, one place to change coordinates. Whether you keep the model's drawing is a separate decision from whether you keep its structure.
That separation is the habit worth building. Output and structure are two different reviews.
A short review checklist
Use the same list for any generated Python, whether it came from a chat window or an agent inside your editor.
Check — Question — Why it matters · Runs clean — Does it execute in a fresh environment? — Catches missing imports and version mismatches · Fails well — What happens on bad input? — Separates a demo from a tool · Names things — Do names describe values? — You will read this code again · Has a seam — Can you change one part safely? — Structure decides your future edit cost · States limits — Does it say what it assumes? — Hidden assumptions become bugs
Five rows is enough. My personal heuristic: if several checks fail, suspect the structure rather than patching one line—but that is a rule of thumb with no empirical backing, so use your judgment.
Why "it ran once" is not the bar
A single successful run is a sample of size one. It proves the code path you exercised works. It says nothing about the paths you did not exercise.
Think about a hypothetical script that reads a config file and prints a setting. Run it with the file present and it works. Run it in a fresh checkout where the file is missing and it raises FileNotFoundError. Both runs are the same code. Only one of them tells you how the code behaves when reality disagrees with it.
There is a second reason. Generated code is often shaped by the prompt, not by your project. The Real Python comparison uses no system prompt. No system prompt means the output reflects the model's out-of-the-box behavior rather than instructions you supplied—useful for seeing defaults, though it is my interpretation, not a claim the write-up makes. Your project has conventions. If the generated code ignores them, it will look foreign in your repository even when it runs.
That is why setting up a Python project so your agent stops guessing pays off: state your layout, your formatter, and your test command up front, and the model has concrete targets to match. Without them, you review style on every pass.
What the comparison cannot tell you
Be careful with informal comparisons. They are useful reading material, and they are not benchmarks.
The Real Python write-up describes its own method plainly: same prompts, no system prompt, results read from returned code and replies. That design shows habits. The excerpt we can see does not describe controlling for model size, sampling settings, or repeated runs, so do not assume it does. Read the comparison as a set of examples you can inspect, not as a ranking. The turtle output is a picture. The command-line answer is a list of language features. Both are evidence about style, not proof of reliability.
The same caution applies to any generated code you receive. The model does not know your data, your users, or your deployment. It knows the prompt. Your review is where the missing context gets added.
A workflow you can repeat
Keep the loop short. Paste the code into a scratch file. Run it. Break it on purpose. Read the structure. Then decide.
When you decide to keep it, add one test that pins the behavior you care about. The test does not need to be elaborate. It needs to fail if someone changes the thing you verified by hand. The post on tests that pass without telling you anything is a good follow-up on why a green check is not the same as understanding—especially when that check is the only thing standing between you and a silent regression.
That habit turns a one-time review into a durable one. The next model output gets checked against the same bar, and the bar does not move.
Further reading
- Python Persistence: When to Move from JSON to SQLite
- The SAST report nobody opens: a triage loop that survives week ten