On 2021-08-23 01:28, Steven D'Aprano 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

I considered that but thought it could be shadowed. After testing, it appears that it can't.
_______________________________________________
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/Y2YDIZETIYJV2R5I5QEJGZSSDVAOYY3Z/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to