Why does False==False in [False] return True?

Question:

A senior of mine demonstrated it and I want to know if this is a flaw or is there some precedence and operator associativity stuff that justifies it.

>>> False==False in [False]
True
Asked By: Satwik

||

Answers:

Python’s comparison operators chain.

False == False in [False]

is evaluated as

(False == False) and (False in [False])

The middle term participates in both comparisons.

I would prefer that in not chain with the other comparison operators.

Answered By: Steven Rumbalski
Categories: questions Tags:
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.