4 ms·
It's not operator precedence, both (True == False) is False and True == (False is False) are true. As explained in the link, it's because of chained comparison
by gpm 7y ago
It's not operator precedence, both (True == False) is False and True == (False is False) are true.
As explained in the link, it's because of chained comparisons, it expands to True == False and False is False. More useful for expressions like 1 < x < 3.
- kazinator 7y agoI don't think that different equalities like "==" and "is" should be chained together; that is completely wrong. If it must be done for consistency in syntax/parsing, then such combinations should be semantically diagnosed and rejected. "x is y is z" -> good. "x == y == z" -> good. "x == y is z" -> WTF, error. All the operators in the "relational cluster" should belong to the same equivalence family.