osdir.com

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Odd truth result with in and ==


On Thu, Nov 22, 2018 at 6:33 AM Python <python at bladeshadow.org> wrote:
> FWIW I meant my expectation is it should be the same as #3 (I confused
> the 2nd item with the second subsequent thing that it did not match)
> since "in" and "==" have the same precedence, and should be evaluated
> in order left to right.  IOW, it should evaluate to True.

Good call on expecting operator precedence. But as mentioned in my
other post (which crossed with your followup), comparisons don't
follow simple associativity.

https://docs.python.org/3/reference/expressions.html#operator-precedence
https://docs.python.org/3/reference/expressions.html#comparisons

ChrisA