Odd truth result with in and ==

Chris Angelico rosuav at gmail.com
Wed Nov 21 14:36:59 EST 2018


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



More information about the Python-list mailing list