[Python-ideas] Add new `Symbol` type

Brett Cannon brett at python.org
Mon Jul 9 17:01:49 EDT 2018


On Fri, 6 Jul 2018 at 09:24 Eric V. Smith <eric at trueblade.com> wrote:

> On 7/6/2018 11:20 AM, Flavio Curella wrote:
> > I think this thread can be resolved as 'used unittest.mock.sentinel'. It
> > doesn't have 'global sentinels', but I'm not convinced they are actually
> > necessary, since `mock.sentinel` objects with the same name compare as
> > equal. Thanks to Nathaniel, I now understand that JS has global symbols
> > for historical reasons that we don't have, and I'm not convinced of
> > their usefulness.
>
> Do all Python distributions ship with unittest.mock? I see to recall
> that Debian and/or Ubuntu strips out part of the normal distribution.
>

It's usually tkinter and such, not unittest stuff from my understanding.


>
> For example, dataclasses.py has a sentinel, and it includes some code to
> get a more helpful repr. It would make sense to re-use the
> unittest.mock.sentinel code, but not if that code isn't always
> guaranteed to be present.
>

Would it make sense to abstract this out to the 'types'  to have a single
'types.sentinel' object for those rare cases that Guido pointed out?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180709/6e5f641a/attachment.html>


More information about the Python-ideas mailing list