# Python Finally Gets a Built-in Sentinel to End the None Confusion

Original title: Much Ado About None: Sentinel Values in Python

> Hacker News story 50297068 · language: en · submitted 2026-10-29
> Web version: https://zeli.app/story/50297068
> About this feed: https://zeli.app/llms.txt · Agent guide: https://zeli.app/skill.md

▲ 72 · by [sebg](<https://news.ycombinator.com/user?id=sebg>) · 💬 49
[original](<https://florianwilhelm.info/2026/10/sentinel_values/>) · [HN discussion](<https://news.ycombinator.com/item?id=50297068>)

## Summary

None in Python is overloaded: it signals missing keys, unset configs, and errors, making ambiguity common. Sentinel values solve this by being outside the domain of valid values. After PEP 661 was deferred, the Steering Council accepted it, and Python 3.15 introduces a built-in sentinel that type checkers can narrow. The author shares takeaways from his talks at PyConDE, EuroPython, and Swiss Python Summit, recommending built-in sentinels over object() and Enum hacks.

## Key quote

> Sentinel values resolve this by being a guard outside the domain of valid values, so they can never collide with an actual value.

## HN discussion (49 comments)

### [pwdisswordfishq](<https://news.ycombinator.com/item?id=50320195>)

> So much trouble to avoid introducing the optional monad.

### [lpghatguy](<https://news.ycombinator.com/item?id=50319854>)

> When I was writing a bunch of Lua, I was a big fan of having a None sentinel value (Lua uses 'nil' for representing absence) and it was useful for a lot of things similar to Pydantic's MISSING.
>
> This distinction is something that I think is actually handy about JavaScript, and distinguishing between 'null' and 'undefined' is sometimes useful for similar reasons.

### [RantyDave](<https://news.ycombinator.com/item?id=50319696>)

> "A simple cache returns None both for a missing key and for a key that maps to None."
>
> No, it returns KeyError. Or at least it should.

### [est](<https://news.ycombinator.com/item?id=50321859>)

> I just return a customized Exception type. Works about the same.

### [throwaway2037](<https://news.ycombinator.com/item?id=50321201>)

> Here is the sample code from the article:
>
> \> MISSING = sentinel("MISSING")
>
> \> def update_email(user_id: int, email: str | None | MISSING = MISSING) -> None:
>
> \>     if email is MISSING:
>
> \>         return  # nothing to update
>
> \>     elif email is None:
>
> \>         db.delete_email(user_id)
>
> \>     else:
>
> \>         db.set_email(user_id, email.lower())  # narrowed to str
>
> I see this style frequently from long time Python programmers.  The language is so dynamic that people begin to think this is a good way to program.  Hot take: It is not.  Why not two different functions called delete_email() and set_email()?  That would be more clear.

---

## Cite

- Page: https://zeli.app/story/50297068
- Date: 2026-10-29
- Source: florianwilhelm.info (https://florianwilhelm.info/2026/10/sentinel_values/)
- Hacker News: https://news.ycombinator.com/item?id=50297068

## Other languages

- zh: https://zeli.app/zh/story/50297068 · markdown: https://zeli.app/zh/story/50297068.md
- ja: https://zeli.app/ja/story/50297068 · markdown: https://zeli.app/ja/story/50297068.md
- ko: https://zeli.app/ko/story/50297068 · markdown: https://zeli.app/ko/story/50297068.md
- de: https://zeli.app/de/story/50297068 · markdown: https://zeli.app/de/story/50297068.md
- es: https://zeli.app/es/story/50297068 · markdown: https://zeli.app/es/story/50297068.md
- ru: https://zeli.app/ru/story/50297068 · markdown: https://zeli.app/ru/story/50297068.md
