On , I learnt ...
You can arbitrarily chain Python comparison operations
Which explains why:
>>> False == False in [False]
True
This odd looking expression is equivalent to
(False == False) and (False in [False])
, hence why it evaluates to True
.
And since there’s no limit to how many comparisons can be chained together, this kind of thing is legal syntax:
>>> False is False == False in [False] in [[False]] not in [False]
True