Opinion

Why Python's Error Messages Need Empathy

Python's famously terse error messages frustrate both beginners and seasoned developers. This piece argues for error messages that guide users toward solutions with context and helpful suggestions, making the language truly accessible for everyone.

July 2026 6 min read 8 views 0 hearts

We've all been there. You're coding at 2 AM, trying to get a script to work before the morning demo. Python throws a SyntaxError, and the message reads: "invalid syntax." That's it. No hint about what went wrong, which line is problematic, or what you might do to fix it. It feels like the language is scolding you for not knowing its rules—and that's a problem.

Python is celebrated as a beginner-friendly language. Its design philosophy emphasizes readability and simplicity. But when it comes to error messages, the language often falls short. It treats users like they should already know the answer, rather than guiding them toward a solution. This isn't just about beginners—even seasoned developers waste time decoding cryptic errors.

Let me give you a real-world example from PythonSkillset's community forums. A user named Maria was building a simple web scraper. She wrote:

for i in range(10):
    print(i)

But she accidentally indented the print statement with a tab instead of spaces. Python's response? "IndentationError: unexpected indent." Maria, a relatively new programmer, spent 20 minutes trying to figure out why—because her code looked correct to her eye. The error message didn't explain where the unexpected indent occurred or what an "unexpected indent" even meant in this context.

Contrast that with Rust's error messages. When you make a mistake, Rust tells you not just what's wrong, but why it matters and how to fix it. For example, if you try to use a variable after moving it, Rust's compiler says something like: "error[E0382]: borrow of moved value: x. Help: consider cloning the value if you need to use it again." That's empathy—it assumes you're intelligent but might need guidance.

Python could learn from this. Instead of "invalid syntax," why not: "SyntaxError at line 5: Missing closing parenthesis after 'print('? Try adding ')' before the next line break." Or instead of "NameError: name 'user_input' is not defined," why not: "It looks like you're trying to use 'user_input', but it hasn't been assigned a value yet. Did you mean to call input() first?"

This isn't just wishful thinking. PythonSkillset's research shows that 68% of beginners cite confusing error messages as their top frustration. And even experienced developers admit they often guess rather than read the error carefully. We're ignoring a core pain point in the user experience.

Some might argue that error messages should be terse because they're read by developers who already understand the language. But that ignores the fact that Python is explicitly designed for people learning to program—including scientists, accountants, and high school students. If the language is truly "for everyone," its error messages should speak to that everyone.

The fix doesn't require a full rewrite of CPython. It could start with community-driven improvements, like adding context to common errors. Pythonskillset's own tutorial on debugging suggests using try/except blocks to catch errors and print user-friendly explanations. But wouldn't it be better if the language itself did that?

Empathy in error messages doesn't mean dumbing down the content. It means acknowledging that making mistakes is part of learning, and the language should help you learn faster. It means saying, "I see what you're trying to do, and here's the gap in your understanding"—not just "you're wrong."

Imagine a future where Python's error messages feel like a mentor looking over your shoulder, not a robot judging your code. That's the kind of language we deserve—one that respects our intelligence but also our humanity.

Comments

Questions, corrections, and tips stay visible for everyone reading this page.

0 in thread

Join the discussion

Shown next to your comment.

Up to 4,000 characters

No comments yet

Be the first to leave a note — it helps the next reader.