True == 1 weirdness

Blake T. Garretson blake.garretson at
Wed Sep 16 15:14:47 CEST 2015

On Wednesday, September 16, 2015 at 8:54:07 AM UTC-4, Jussi Piitulainen wrote:
> The second test, test2, is interpreted (almost) as
>   >>>> (1 in {1:1}) and ({1:1} == 1)
> which is obviously False.

Ah, that makes sense.  It didn't occur to me that Python would interpret it that way, and I've been using Python daily for 15 years.  I try to avoid ambiguous chained comparisons, and I use parenthesis even when I don't need them for clarity.  Thanks!

More information about the Python-list mailing list