Thibault Langlois <thibault.langl...@gmail.com> Wrote in message: > Hello, > > $ python > Python 2.7.4 (default, Sep 26 2013, 03:20:26) > [GCC 4.7.3] on linux2 > Type "help", "copyright", "credits" or "license" for more information. >>>> 1 > 0 == True > False >>>> (1 > 0) == True > True >>>> 1 > (0 == True) > True >>>> > > What am I missing here ? > > T. >
You tell us. You supply only half the question, what it does, without saying what you expected or needed. I expect you're either confused about comparison chaining or about what happens when you compare objects of different types. Doing an ordered comparison between two types is undefined by default, and not guaranteed to even give the same result between builds. So the following may give different results on your 2.7.4 than on mine. 5 < "abc" Python 3 fixes that by throwing an exception. TypeError: unorderable types This should solve it, since the first and third expression would seem to be undefined. Unfortunately there's yet another wrinkle. For hysterical reasons, True and False are instances of class bool, which is derived from int. So for comparison purposes False==0 and True==1. But in my opinion, you should never take advantage of this, except when entering obfuscation contests. -- DaveA -- https://mail.python.org/mailman/listinfo/python-list