File: sentinel.rst

package info (click to toggle)
python-collections-extended 2.0.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 492 kB
  • sloc: python: 2,917; makefile: 59
file content (17 lines) | stat: -rw-r--r-- 574 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
Sentinel
========

This is a small class that improves upon using a plain object
as a sentinel for function arguments when None is a valid
parameter and can't be used as the default. The improvements
vs. a plain object are:

* Better ``__str__`` and ``__repr__`` for better messages in
  logs and stacktraces. Instead of something like
  ``'<object object at 0x7ffb4d50e830>'`` you get ``'<not_set>'``
* Sentinels are picklable

See: https://en.wikipedia.org/wiki/Sentinel_value
Inspired by: https://pypi.org/project/sentinels/

.. autoclass:: collections_extended.sentinel