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 -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/NNMPGIHGEKCNPHR5OBXE4BXW3LMJ77HN/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to