skillfed

sentinel

Create sentinel objects, akin to None, NotImplemented, Ellipsis

sentinel v1.0.0 146.5K downloads/30d#11,098 on PyPI28
Permissive license MIT Abandoned released

What it is and what it does

Sentinel creates lightweight singleton objects that act as unique markers, similar to Python's built-in None, NotImplemented, and Ellipsis. Each sentinel is the only instance of its own anonymous class, making it safe to compare with `is` rather than `==`. This is useful when you need to distinguish a truly missing or unset value from legitimate falsy values like 0, False, or None that might actually be stored in a data structure.

The package supports pickling, deepcopy, and allows you to attach custom methods and attributes to sentinels. It has an optional feature (via the varname extra) to infer sentinel names from assignment expressions, reducing boilerplate. With zero runtime dependencies and support for Python 3.6+, it's a minimal utility for cases where None alone is insufficient as a sentinel.

Use it for:

  • Distinguish missing dictionary entries from stored None or falsy values using dict.get() with a sentinel default.
  • Set meaningful default values in dict.setdefault() when all other values (including 0, False, None) are valid.
  • Mark leaf nodes or terminal states in tree or graph structures with a singleton that can be checked with `is`.
  • Create self-documenting API return values that signal special conditions without overloading None or raising exceptions.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Creates singleton sentinel objects that represent special terminating conditions or symbolic meanings, allowing you to distinguish missing values from falsy ones like None, 0, or False.

Yes, if you need sentinel objects for a small, self-contained utility. The package is stable, has no dependencies, and solves a real problem cleanly. However, the abandoned status (last commit 2022-07-23) means no future maintenance or Python 4 support—acceptable for a mature, narrow-scope library but worth noting if you depend on active upstream development.

Install

sentinel on PyPI

pip

pip install sentinel

uv

uv add sentinel

poetry

poetry add sentinel

Installing sentinel

Before you install

Low friction installation with no runtime dependencies. Package is marked abandoned (last commit 2022-07-23), though it remains stable and compatible with Python 3.6 through 3.10.

License in practice

MIT license permits unrestricted use, modification, and distribution with minimal restrictions—suitable for both open and closed-source projects.

Quickstart

pip install sentinel

import sentinel

Missing = sentinel.create("Missing")
if d.get("key", Missing) is Missing:
    print("Key not found")

Verify before relying

  • Whether the abandoned status and 2022 last commit affect real-world reliability for typical use cases.
  • Whether python-varname extra (for name inference) remains compatible with current python-varname versions.

Package facts

License MIT (permissive)
Python support supports the current Python release (>=3.6,<4.0)
Install friction low — pure-Python wheel
Runtime dependencies none
Maintenance abandoned — 1,483 days since the last release
Last repo commit
First released
Downloads 146,455/month — #11,098 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: sentinel-1.0.0-py3-none-any.whl

Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: Software Development :: Libraries :: Python Modules

Tags

sentinel objects pythonsingleton pattern implementationmissing value markerdistinguish none from missingspecial symbolic objectsterminating condition marker
singleton-patterndesign-pattern

More Python Modules packages