Sorry about my detour into the rejected idea of a factory function.
But how about this class-based API?
class NotGiven(Sentinel): pass
Now I can use NotGiven as the sentinel, and its default repr is <NotGiven>.
Behind the scenes we can have a SentinelMeta metaclass with all the magic that could be required--including the default __repr__ method.
Cheers,
Luciano
(Note: This link will break once the temporary branch is deleted.)
I wrote it to summarize the discussions, organize my thoughts and explore the options. I stopped working on it late at night and sent a link to a few people to get some opinions. I didn’t intend to make it public yet, but it was noticed and replied to on the discuss.python.org thread where I put up the poll [1], so the cat is out of the proverbial bag now…
Luciano, your wish is granted! ;)
- Tal Einat
[1] https://discuss.python.org/t/sentinel-values-in-the-stdlib/8810/
-- Luciano Ramalho | Author of Fluent Python (O'Reilly, 2015) | http://shop.oreilly.com/product/0636920032519.do | Technical Principal at ThoughtWorks | Twitter: @ramalhoorg