sentinel#

simpletype.sentinel.make_sentinel(name='_MISSING', var_name=None)[source]#

Creates and returns a new instance of a new class, suitable for usage as a “sentinel”, a kind of singleton often used to indicate a value is missing when None is a valid input. Args:

name (str): Name of the Sentinel var_name (str): Set this name to the name of the variable in

its respective module enable pickleability. Note: pickleable sentinels should be global constants at the top level of their module.

>>> make_sentinel(var_name='_MISSING')
_MISSING
The most common use cases here in boltons are as default values
for optional function arguments, partly because of its
less-confusing appearance in automatically generated
documentation. Sentinels also function well as placeholders in queues
and linked lists.
.. note::
  By design, additional calls to ``make_sentinel`` with the same
  values will not produce equivalent objects.
  >>> make_sentinel('TEST') == make_sentinel('TEST')
  False
  >>> type(make_sentinel('TEST')) == type(make_sentinel('TEST'))
  False