24 May
2021
24 May
'21
3:06 a.m.
On 2021-05-24 01:37, Luciano Ramalho wrote:
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>.
The repr of other singletons are the names of those singletons, eg. "None", so why "<NotGiven>" instead of "NotGiven"?
Behind the scenes we can have a SentinelMeta metaclass with all the magic that could be required--including the default __repr__ method.