sethserver.com

Python

Python

Recursively List Files in Python: os.walk vs pathlib

Updated: June 29, 2026

Two ways to crawl a directory tree in Python: `os.walk()` and `pathlib`. Both work, but `os.walk()` has a classic trap-`dirnames` and `filenames` are names, not full paths-so one missing `os.path.join()` can send your script wandering into the wrong folder. This post shows safe patterns for each approach, how to prune noisy dirs like `node_modules`, and why `Path(...).rglob()` is usually the "hard to break" choice-especially once you start hunting down those mysterious duplicate CSVs. read on »

Python

Fix "Object of type X is not JSON serializable" in Python

Updated: June 29, 2026

That "Decimal is not JSON serializable" crash isn't random. JSON only supports a tiny set of types, and Python refuses to guess conversions that can quietly corrupt data (hello, billing). The fix isn't `default=str`. It's picking explicit encoding rules once-Decimal to string, datetime to ISO-8601, UUID to string, Enum to `.value`, dataclasses to `asdict()`-and using them everywhere with `json.dumps(..., default=...)`. read on »

Python

Python Slice Notation: A Complete Guide to start:stop:step Syntax

Updated: April 15, 2026

I kept re-learning Python slices because my brain refused to accept "stop is exclusive." Then I started doing LLM work and suddenly slices were everywhere: token windows, chunking, sliding overlap, all of it. This post nails the only three rules you need (`start:stop:step`), the five slice patterns I actually use, and why "exclusive stop" is the reason chunking doesn’t turn into off-by-one misery. read on »

Newsletter

One email, once a week.

Notes on databases, systems, and the occasional strong opinion about Python. No spam, unsubscribe anytime.