On Apr 24, 12:08 am, Dan Bishop <[EMAIL PROTECTED]> wrote: > On Apr 23, 11:51 pm, Greg J <[EMAIL PROTECTED]> wrote: > > > I was reading the programming Reddit tonight and came across this > > (http://reddit.com/info/6gwk1/comments/): > > > >>> ([1]>2)==True > > True > > >>> [1]>(2==True) > > True > > >>> [1]>2==True > > > False > > > Odd, no? > > > So, can anyone here shed light on this one? > > A long time ago, it wasn't possible for comparison operators to raise > exceptions, so it was arbitrarily decided that numbers are less than > strings. Thus, [1]>2 and [1]>False. This explains your first two > examples.
Sure, those I understood. > For the third, remember that the comparison operators are chained, so > a>b==c means (a>b) and (b==c). Since 2==True is false, so is the > entire expression. Ach! Of course. For some reason I was blanking on the chained nature of relational operators in Python. Thanks for the reminder! > > In Python 3.0, all three of these expressions will raise a TypeError. -- http://mail.python.org/mailman/listinfo/python-list