[Python-ideas] True and False are singletons
shoyer at gmail.com
Mon Mar 18 18:52:33 EDT 2019
On Mon, Mar 18, 2019 at 3:42 PM Greg Ewing <greg.ewing at canterbury.ac.nz>
> Tim Delaney wrote:
> > I would argue the opposite - the use of "is" shows a clear knowledge
> > that True and False are each a singleton and the author explicitly
> > intended to use them that way.
> I don't think you can infer that. It could equally well be someone who's
> *not* familiar with Python truth rules and really just meant "if x".
> Or someone who's unfamiliar with booleans in general and thinks that
> every "if" statement has to have a comparison in it.
Regardless of whether it's idiomatic Python code or not, this pattern ("is
True:") can be found all over Python code in the wild.
If CPython ever broke this guarantee, quite a few popular libraries on pypi
would be broken, including pandas, sqlalchemy, attrs and even Python's own
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-ideas