3 ms·
What's the advantage of make_sentinel vs just doing _MISSING = object()?
by Sean1708 8y ago
What's the advantage of make_sentinel vs just doing _MISSING = object()?
- nerdponx 8y agoA Sentinel is guaranteed unique and distinct from all other objects.
- Sean1708 8y agoI'm fairly sure object() also returns an object which is unique and distinct from all other objects. The only difference as far as I can see is that make_sentinel returns an object that has a unique and distinct type from all other objects, but I don't see why you'd be checking the type of your sentinels in Python.
- mhashemi 8y agoHehe, boltons.typeutils.make_sentinel should really be documented better for more experienced developers. A few small advantages: a nice repr, pickleability, and (back to the first advantage really) good rendering in a Sphinx autodoc context. :)
- doublereedkurt 8y agoa nice __repr__ is the main thing