{"id":22349,"library":"sentinel","title":"sentinel","description":"Create sentinel objects, akin to None, NotImplemented, Ellipsis. Provides a simple way to define unique sentinel values for signaling special conditions (e.g., default arguments, missing data). Current version: 1.0.0. Release cadence: infrequent, stable.","status":"active","version":"1.0.0","language":"python","source_language":"en","source_url":"https://github.com/eddieantonio/sentinel","tags":["sentinel","sentinel-values","defaults","marker","utility"],"install":[{"cmd":"pip install sentinel","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"Used for Python 2/3 compatibility (though library requires >=3.6, included for historical reasons)","package":"six","optional":true}],"imports":[{"note":"Class is capitalized; lowercase import will raise ImportError","wrong":"from sentinel import sentinel","symbol":"Sentinel","correct":"from sentinel import Sentinel"}],"quickstart":{"code":"from sentinel import Sentinel\n\n# Create a unique sentinel\nNotGiven = Sentinel('NotGiven')\n\ndef get_value(key, default=NotGiven):\n    if default is NotGiven:\n        print('No default provided')\n    else:\n        print(f'Default is {default}')\n\nget_value('foo')\nget_value('foo', default='bar')","lang":"python","description":"Creates a sentinel object to use as a default argument marker."},"warnings":[{"fix":"Always assign the sentinel to a module-level variable (e.g., _MISSING = Sentinel('MISSING')) and import that variable.","message":"Sentinel instances are not singletons by default; each call to Sentinel('name') creates a new instance. Use a module-level constant to maintain identity.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"If pickling is needed, use sentinel's __reduce__ method or define a custom sentinel class.","message":"Sentinel objects cannot be pickled by default. Attempting to pickle a sentinel will raise a PicklingError.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Always use 'is' for comparison, not '=='.","message":"Sentinel instances compare by identity, not value. Using == may give unexpected results if the sentinel is not the exact same object.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Use: from sentinel import Sentinel","cause":"Attempting to import the lowercase 'sentinel' instead of the class 'Sentinel'.","error":"ImportError: cannot import name 'sentinel' from 'sentinel'"},{"fix":"Run: pip install --upgrade sentinel","cause":"The library may not be installed correctly, or an older version without the Sentinel class is installed. (Library has always had Sentinel class, but check version.)","error":"AttributeError: module 'sentinel' has no attribute 'Sentinel'"},{"fix":"Define a custom pickle behavior: See https://github.com/eddieantonio/sentinel#pickling","cause":"Trying to pickle a sentinel instance without proper __reduce__ implementation.","error":"PicklingError: Can't pickle <class 'sentinel.Sentinel'>: it's not found as sentinel.Sentinel"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}