A blog about writing calmer Python

Python tips that actually stick, one habit at a time.

I'm Hoang Quoc Dat. I write short, practical notes on the small Python habits that make code easier to read, easier to trust, and a little more fun to write.

QD
Hoang Quoc Dat Writer, Python Notes

Why another Python blog?

Most Python content either stays at "hello world" or jumps straight to frameworks and buzzwords. I wanted a middle ground: short, honest posts about the habits that quietly make a codebase better — naming, structure, small refactors, and the standard library features that don't get enough credit.

Every tip on this page is something I've actually used in real projects, not just read about. My goal isn't to impress you with clever one-liners — it's to help you write Python that your future self, and your teammates, will thank you for.

A few tips to start with

Small changes, picked for how often they come up in everyday code.

Reach for comprehensions, not loops

When you're building a new list, set, or dict from an existing one, a comprehension usually reads clearer than a manual loop with .append(). It keeps the "what" separate from the "how," and it's often faster too.

squares = [n**2 for n in range(10) if n % 2 == 0]

Use enumerate() over range(len())

If you need both the index and the value while looping, enumerate() says exactly that in one word. It removes an entire class of off-by-one bugs and makes the intent obvious to anyone reading it later.

for i, item in enumerate(items):

Let f-strings do the formatting

f-strings are easier to read than %-formatting or .format(), and they let you call functions or do quick math directly inside the braces. They've become the default for a reason.

print(f"{name} scored {score:.1f}%")

Keep every project in its own virtual environment

A fresh venv per project keeps dependencies from bleeding into each other, and it means "it works on my machine" becomes a much rarer excuse. Pair it with a pinned requirements file and future you will be grateful.

python -m venv .venv && source .venv/bin/activate

New tips land every couple of weeks.

No spam, no growth-hacking newsletters — just the same short, practical notes on writing calmer Python.

Get new tips by email