Sentinel values in Python

When None and Blank Are Both Valid Inputs, Reach for Sentinel Values (Python 3.15)

Here is a problem I keep running into. We take a few optional inputs from the user. Say a profile form with nickname, bio, and website. For each field, the user can do one of three things: Leave it untouched, never type anything into it. Clear it out on purpose, submit it blank. Fill it in with a real value. These are three different intentions, and the service that saves the form has to respect all three. Untouched should leave whatever is already stored. Blank should wipe it. And a real value should be saved as is. ...

June 11, 2026 · 5 min · Nazrul