[Python-ideas] True and False are singletons

Rémi Lapeyre remi.lapeyre at henki.fr
Mon Mar 18 07:21:43 EDT 2019

Le 18 mars 2019 à 12:15:05, Juancarlo Añez
(apalala at gmail.com(mailto:apalala at gmail.com)) a écrit:

> It came to my attention that:
> > In the original PEP True and False are said to be singletons https://www.python.org/dev/peps/pep-0285/, but it's not in the Data Model https://docs.python.org/3/reference/datamodel.html
> This came to my attention by code wanting to own the valid values in a dict's key:
> > if settings[MY_KEY] is True:
> > ...
> >
> If True and False are singletons in the spec (and not only in the CPython implementation), it should be prominent and well known.

I think it’s what "The two objects representing the values False and
True are the only Boolean objects." mean.


> Cheers,
> --
> Juancarlo Añez _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/

More information about the Python-ideas mailing list