Skip to main content

Sentinel Values - unique objects akin to None, True, False

Project description

Python package version Tests Status Documentation Status

sentinel-value is a Python package, that helps to create Sentinel Values - special singleton objects, akin to None, NotImplemented and Ellipsis.

It implements the sentinel() function (described by PEP 661), and for advanced cases it also provides the SentinelValue() class (not a part of PEP 661).

Usage example:

from sentinel_value import sentinel

MISSING = sentinel("MISSING")

def get_something(default=MISSING):
    ...
    if default is not MISSING:
        return default
    ...

Or, the same thing, but using the SentinelValue class (slightly more verbose, but allows to have nice type annotations):

from typing import Union
from sentinel_value import SentinelValue

class Missing(SentinelValue):
    pass

MISSING = Missing(__name__, "MISSING")

def get_something(default: Union[str, Missing] = MISSING):
    ...
    if default is not MISSING:
        return default
    ...

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sentinel-value-1.0.0.tar.gz (7.3 kB view details)

Uploaded Source

Built Distribution

sentinel_value-1.0.0-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file sentinel-value-1.0.0.tar.gz.

File metadata

  • Download URL: sentinel-value-1.0.0.tar.gz
  • Upload date:
  • Size: 7.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.8.1 requests/2.26.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.6.15

File hashes

Hashes for sentinel-value-1.0.0.tar.gz
Algorithm Hash digest
SHA256 2ff8e9e303c8f6abb2ad8c6d2615ed5f11061eeda2e51edfd560dc0567de633a
MD5 b10a73706db43df80736c288dde5a524
BLAKE2b-256 938096226b2523d52d88272bd960271a496ae468bb815180bf8a4c38b63b6390

See more details on using hashes here.

File details

Details for the file sentinel_value-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: sentinel_value-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 7.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.8.1 requests/2.26.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.6.15

File hashes

Hashes for sentinel_value-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fab2501cb3f40c412a105b9a93089780c571468963f7bbcd0b5772ecdcfdc8cc
MD5 f964d85190ed1cc41018d9bcf3bd29e0
BLAKE2b-256 29d0757561b23d945e9f7431306a8dc2e60425115df55cef1d142ab52132e08f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page