On Sat, Sep 10, 2022 at 6:58 AM Tal Einat <[email protected]> wrote:
> > > The sentinel objects should behave as expected by a sentinel object:
> When compared using
> > > the is operator, it should always be considered identical to itself
> but never to any other object.
>
> The current design is that sentinels with the same name from the same
> module will always be identical. So for example `Sentinel("name") is
> Sentinel("name")` will be true.
Hmm -- so it's a semi-singleton -- i.e. behaves like a singlton, but only
in a particular module namespace.
I wonder if there's a way to make this a bit more clear in the PEP text --
but don't have any suggestions for edits at the moment :-(
It would be nice if they could be true singletons, but that would require a
python-global registry of some sort, which is, well, impossible.
I would like to see a handful of common sentinels defined. Is there a plan
to put a few that are useful for the stdlib in the `sentinel` module?
Maybe that doesn't belong in the PEP, but I like the idea of
a) every similar use in the stdlib uses the same one
and
b) having a standard set for third party code to use -- a bit like the
built-in Exceptions.
-CHB
--
Christopher Barker, PhD (Chris)
Python Language Consulting
- Teaching
- Scientific Software Development
- Desktop GUI and Web Development
- wxPython, numpy, scipy, Cython
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/DB4TBITP5VCKME3CSE4A2Y5PL7OUIGM5/
Code of Conduct: http://python.org/psf/codeofconduct/