On Sun, Sep 11, 2022 at 4:55 AM Steven D'Aprano <st...@pearwood.info> wrote:
>
> I haven't read the PEP yet, so this should not be read as either support
> of or opposition to the design, just commenting on one aspect.

Given what you've written, I recommend reading it. It's relatively
short and directly addresses what you've brought up here.

> On Sat, Sep 10, 2022 at 01:42:38PM -0700, Christopher Barker wrote:
>
> > > 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.
> [...]
> > 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.
>
> Easy peasey. Add a second, optional, parameter to the Sentinel callable
> (class?) to specify the namespace, defaulting to "the current module",
> then register the object to `builtins`.

This already exists, an optional "module_name" argument, which
defaults to the current module (via frame inspection). Using the same
name and module name will result in the same sentinel object.

> Do you have examples of such stdlib "similar use" of sentinels? Apart
> from None of course.

The PEP includes a link to a list of sentinel values in the stdlib [1].

- Tal

[1] 
https://mail.python.org/archives/list/python-...@python.org/message/JBYXQH3NV3YBF7P2HLHB5CD6V3GVTY55/
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/Z5ZXFGAIXUFDQUSAPDM5HBCPMEEEWBSY/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to