Odd truth result with in and ==

Frank Millman frank at chagford.com
Sat Nov 24 00:33:51 EST 2018


"John Pote"  wrote in message 
news:e0a8e1bc-6e03-e42b-d6e8-d690e2d5a10f at jptechnical.co.uk...
>
> I interpret the above comparison as
>
>  >>> bool([1,2,3]) == bool(True)
> True
>  >>>
>

A tiny addition to what has already been said.

As True is by definition a boolean, you can write this as

>>> bool([1, 2, 3]) == True
True
>>>

I have on vary rare occasions had to convert 'truthiness' to an actual 
boolean, and this is how I do it.

Frank Millman









More information about the Python-list mailing list