
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
- Tweets86.6K
- Following168
- Followers267K
- Likes57.1K
Big news: the Real Python team just launched RealJS 🎉
Same team, same way of teaching, now for JavaScript.
It's live today, and it has its own home on X: @learnrealjs 🧵
"Testing every edge case means writing a dozen near-copies of the same test."
Not with pytest. One test function can run many scenarios.
The tutorial also shows when a fixture helps and when to skip it.
realpython.com/pytest-python…
1
9
1,564
That boring task you redo every Friday? Python can take it off your hands this week.
Free kit: cheat sheet → working code → full video course → quiz to check yourself.
realpython.com/kits/automati…
1,306
You and Claude Code both ran code in the same analysis. Which lines were yours?
In Positron, code an agent runs in the console is marked as the agent's, so the history shows who ran what.
Isabel Zimmerman on why that matters when you need to trust it:
realpython.com/podcasts/rpp/…
Does your code take both pandas and Polars, or did your team pick one?
The tutorial ends with an exercise that joins a DataFrame to a LazyFrame.
realpython.com/narwhals-pyth…
485
5. Pass a Polars LazyFrame to a Narwhals function that calls .pivot() and you get:
AttributeError: 'LazyFrame' object has no attribute 'pivot'
A pivot needs data a LazyFrame hasn't loaded yet. from_native(df, eager_only=True) fails up front with a TypeError instead.
1
470
4. End with .to_polars() instead of .to_native() and you always get a Polars DataFrame back, even when the caller passed in pandas.
If you want the caller's type back, the @nw.narwhalify decorator makes both conversion calls for you.
1
19
3. Narwhals DataFrames have no index, like Polars. So what happens to a pandas index?
Narwhals ignores it during the analysis and puts it back when .to_native() returns the result. pandas callers get their index, Polars callers never see one.
1
22
2. Narwhals doesn't copy your data.
It wraps the DataFrame, translates your expressions into the original library's calls, and lets pandas or Polars do the work. You keep that library's speed and memory use.
1
66
1. Wrap the input with nw.from_native(df), write Polars-style expressions, and finish with .to_native().
pandas comes back as pandas, Polars as Polars, and a Polars LazyFrame as a LazyFrame.
The function never imports pandas or Polars.
1
74
Your function takes a pandas DataFrame. A teammate passes it a Polars one.
The Narwhals library lets one function take both and return what it got:
1. pandas in, pandas out
2. No copy of your data
3. pandas keeps its index
4. Picking the output type
5. A LazyFrame trap
🧵
1
4
2,975
Writing an MCP server and tired of guessing if it works?
Build a small command-line client that lists its tools, prompts and resources, then lets an AI chat call those tools.
realpython.com/python-mcp-cl…
Calling Meta's Muse Spark from Python? Set reasoning effort to "minimal."
In the tutorial's test it cut latency by more than half and cost by about 60%, with no loss in accuracy.
Open-weights Glimmer answered the same question for about 1/8 of the cost.
realpython.com/meta-muse-pyt…
4
1,315
Would you pay $20/month for Claude Code's stricter error handling, or stay on Gemini CLI's free tier?
The tutorial has both apps' code and a decision table.
realpython.com/gemini-cli-vs…
474
5. Type /exit in Gemini CLI and you get a token breakdown. The to-do runs averaged 44,640 input and 3,772 output tokens, about $0.03 a run at API prices and $0 on the free tier.
Claude Code's $20/month Pro plan doesn't split input and output tokens at session end.
1
1
465
4. Same model, same prompt, same hour: Gemini CLI wrote 3 files, then 6, then 8, with thorough docstrings in only one run.
Claude Code went from 3 files to 2, and added a created_at field nobody asked for.
Neither tool gave the same project structure twice.
1
59
3. Same to-do app prompt, three runs each: Claude Code averaged 1 min 44.7 s, Gemini CLI 2 min 36.3 s.
Claude Code also wrote twice the code: 414.7 lines vs 198.
On SWE-bench Verified (March 2026) the models nearly tie: Gemini 3 Flash (free tier) 75.4%, Claude Sonnet 4.6 75.2%.
1
66
2. Ask Gemini CLI's version to add a task that's only spaces and it saves it.
Claude Code's version strips the text and raises ValueError: Task description cannot be empty.
Claude Code's also refuses to complete a task twice. Gemini CLI's returns True both times.
1
97
1. Gemini CLI's to-do app catches a broken tasks.json, prints an error and carries on with an empty list.
Add one task and it overwrites the file with just that task. The others are gone.
Claude Code's version raises ValueError and its CLI exits with code 1, writing nothing.

ALT Python REPL session with the to-do code Gemini CLI generated. A comment says tasks.json held 3 tasks and got cut off. Creating TodoManager() prints 'Error loading tasks: Expecting value: line 14 column 24 (char 238)', and m.tasks is an empty list. After m.add_task("Buy milk"), a fresh TodoManager() has only 1 task: the 3 old tasks were overwritten.
1
116
Gemini CLI and Claude Code, same prompt, three runs each: a Python to-do CLI with JSON storage and unit tests.
All tests passed. Read the code, though:
1. A cut-off tasks.json
2. A blank task
3. Faster, with twice the code
4. 3, 6 or 8 files
5. Who itemizes tokens
🧵
Know Python but your project needs JavaScript?
RealJS is live: same team and teaching as Real Python, 100+ courses, hundreds of exercises and an AI mentor. Three learning paths are built for Python developers.
And Real Python stays right where it is 👇
realpython.com/introducing-r…
6
1,557
