4 ms·
Okay, I don't get this one: >>> False == False in [False] True
by jaibot 11y ago
Okay, I don't get this one:
>>> False == False in [False]
True
- julian37 11y agoBoth "in" and "==" are comparison operators that can be chained and so it's interpreted as False == False and False in [False] https://twitter.com/marcusaureliusf/status/557948873009037312 https://twitter.com/marcusaureliusf/status/55794887300903731...
- bpicolo 11y ago>>> 1 in [1] in [[1]] True
- ubernostrum 11y agoAgain, chained comparisons. For any comparison operator (comparison operators are <, >, ==, >=, <=, <>, !=, 'is', 'not', 'is not', 'in' and 'not in'): x (operator1) y (operator2) z is defined by the language as equivalent to (x (operator1) y) and (y (operator2) z) So 1 in [1] in [[1]] is equivalent to (1 in [1]) and ([1] in [[1]]) For any comparison operator
- tcdent 11y agoI tend to write complex conditionals with parenthesis, sometimes excessively, but the clarity and guarantee of correct evaluation far outweighs any brevity. >>> False == (False in [False, ]) False