Real Python (@realpython) header
Real Python (@realpython) profile picture

Helping Python developers build with AI: apps, agents, models, and AI-assisted coding. Expert-reviewed tutorials and courses, read by 1M+ developers a month.

Joined August 2012
2. argparse's required=True makes a flag mandatory, but it accepts an empty string as the value. So the contacts CLI's add --name "" --email "" --phone "" saves a blank contact, and list shows an empty row. Claude Code's bug review flagged it after the happy-path tests passed.
1
2
98
1. Claude Code's contacts CLI reads a CSV with csv.DictReader. One row with no phone field crashes its table printer. DictReader fills missing fields with None, so len() raises TypeError. Passing restval="" to DictReader fills the gaps with empty strings instead.
1
2
120
2. Ask the agent's delete endpoint to remove car 999, which doesn't exist. It returns 200 OK with an error body. A client that checks status codes thinks it worked. The existing get endpoint returns 404. An AGENTS.md rule to preserve existing endpoints' response shape fixed it.
1
2
83
1. An AI coding agent numbered new cars with len(cars) + 1. Delete car 2 of 3, add a car, and the new one gets id 3. Two cars now share an ID that should be unique. One AGENTS.md sentence saying id is unique and server-assigned got the agent to use the highest id + 1.
1
2
97
An AI coding agent wrote these FastAPI endpoints from a plain prompt to add create and delete. They run, with 7 problems. What a short AGENTS.md file changes: 1. Duplicate IDs 2. 200 OK for a missing car 3. Defining done 4. Agents deleting tests 5. File length 🧵
7
13
2,227
"Write a Python turtle program that draws a python reading a book." DaisyRose 27B wrote 220 lines of code and gave its coiled green snake a pair of round reading glasses. Here’s how it did on five everyday Python tasks 🧵
1
1
7
1,942
4. Got two versions of a dataset, or a train/test split? Profile each one and call .compare() for a side-by-side report of where the distributions moved. The tutorial compares flights out of LAX and ATL. Delta (DL) leads in Atlanta and SkyWest (OO) in Los Angeles.
1
77
2. The old ydata-profiling imports pkg_resources from setuptools. Newer setuptools dropped it, and Python 3.12+ venvs ship without setuptools. Either way, the import fails with ModuleNotFoundError: No module named 'pkg_resources'. On the old package, install setuptools<81.
1
2
53
YData Profiling turns a pandas DataFrame into an HTML report of missing values, correlations and data quality warnings in two lines. Before you use it at work: 1. It has a new name 2. setuptools can break it 3. One flag for speed 4. Diff two datasets 5. When to skip it 🧵
1
16
2,276
"Write a Python turtle program that draws a python reading a book." Inkling 2 Mini wrote 102 lines and 181 drawing commands. The snake waves above an open red book, and its forked tongue floats in the air beside its head. Here's how it did on 5 everyday Python tasks 🧵
1
2
1
9
1,874
1. The fix is a single line: return df.loc[df["Humidity"] >= target] It returns the same rows without a Python loop. In Spyder's Profiler, total time dropped from 3.73 s to 905.33 µs. If pandas has a built-in way to filter rows, use it before you write an iterrows() loop.
1
3
98
This pandas function loops with iterrows() to keep rows with humidity ≥ 0.90. The Spyder IDE's Profiler timed it at 3.73 s. 5 things to know: 1. The one-line fix: 905 µs 2. Why local time said 62 ms 3. Comparing runs 4. Edits your CSV never sees 5. When to skip Spyder 🧵
1
1
15
3,133