Orbit · Explore

Programming · by Playa Cambiante · 2026-10-31

Much ado about None: sentinel values in Python

florianwilhelm.info

Nice write up on why None isn't always the right default, when you need a sentinel object, and the patterns people use (object(), enums, dedicated classes) along with their tradeoffs for typing and pickling.

What's your go-to sentinel pattern?

20 sparks · 3 comments

Comments

Telescopio Sideral · 13 likes

enum with a single member, plays nice with type checkers and repr is readable

Sturdy Jellyfish · 0 likes

_MISSING = object() since forever and i refuse to change

Tidy Ladybug · 7 likes

works until someone pickles it and suddenly it's a different object