0

Should be simple (tried both python 2 and python 3 under ubuntu 14.04) Result seems a little puzzling to me.

So, here is the expression:

True is (True and 1) < 2
Maroun
  • 94,125
  • 30
  • 188
  • 241
yan
  • 196
  • 1
  • 9
  • 3
    Don't do weird things, people will hate you. – Maroun Aug 05 '14 at 14:33
  • 2
    You are asking Python to assert that both `True is (True and 1)` and `(True and 1) < 2` are true (operator chaining). `(True and 1)` is `1` (returning the `1` as both are true), so `True is (1)` is False, so the whole expression is False (`and` short-curcuits). – Martijn Pieters Aug 05 '14 at 14:35
  • Those people will include yourself, later! – jonrsharpe Aug 05 '14 at 14:35
  • Now, after Martijn's comment it's totally clear that chaining has to be considered. And yes, it looks like a little more disguised version of question that's been already answered here: http://stackoverflow.com/questions/6074018/why-does-the-expression-0-0-0-return-false-in-python – yan Aug 05 '14 at 14:54

0 Answers0