Everyone in this thread should absolutely read Lewis Caroll's delightful and "What the Tortoise Said to Achilles."  It's a very short 3-page story that addressed exactly this topic in 1895... even before Guido's Time Machine.

One free copy of the public domain work is at:

  https://wmpeople.wm.edu/asset/index/cvance/Carroll

On Sun, Aug 22, 2021 at 8:30 PM Steven D'Aprano <steve@pearwood.info> wrote:
On Sun, Aug 22, 2021 at 07:01:28PM +0300, Serhiy Storchaka wrote:

>     (len(collection) == 0) is True

Ha ha, yes, very good, you got me. But the trouble is, if you don't
trust the truth value of the predicate, it is hard to know when to
stop:

    len(collection) == 0
    (len(collection) == 0) is True
    ((len(collection) == 0) is True) is True
    (((len(collection) == 0) is True) is True) is True
    ((((len(collection) == 0) is True) is True)) is True
    # ...

*wink*

MRAB and Ricky:

`__builtins__` is a CPython implementation detail and is reserved for
the interpreter's private use. Other implementations may not even have
it. The right way to write your code should be

    import builtins
    builtins.bool((builtins.len(collection) == 0) is True) is True


--
Steve
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-leave@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/NNMPGIHGEKCNPHR5OBXE4BXW3LMJ77HN/
Code of Conduct: http://python.org/psf/codeofconduct/


--
Keeping medicines from the bloodstreams of the sick; food
from the bellies of the hungry; books from the hands of the
uneducated; technology from the underdeveloped; and putting
advocates of freedom in prisons.  Intellectual property is
to the 21st century what the slave trade was to the 16th.