Re: Weird expression result

2008-08-18 Thread Dan Lenski
On Mon, 18 Aug 2008 18:27:53 +0200, Peter Otten wrote: > Dan Lenski wrote: >> How does this play with standard precedence rules? > > Simple, all comparisons have the same priority: > > http://docs.python.org/ref/comparisons.html > > Peter I see. So, since the comparison operators have lower p

Re: Weird expression result

2008-08-18 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: 3 in [3] == True http://docs.python.org/ref[3/summary.html that page is broken, as recently mentioned; "in", "not in", "is", and "is not" are comparison operators too, chains in the same way as the others. for details, see: http://docs.python.org/ref/compari

Re: Weird expression result

2008-08-18 Thread George Sakkis
On Aug 18, 12:04 pm, Peter Otten <[EMAIL PROTECTED]> wrote: > George Sakkis wrote: > > I'm probably missing something obvious but I can't put my finger on > > it: > > (3 in [3]) == True > > True > > 3 in ([3] == True) > > Traceback (most recent call last): > > File "", line 1, in > >

Re: Weird expression result

2008-08-18 Thread Peter Otten
Dan Lenski wrote: > On Mon, 18 Aug 2008 18:04:32 +0200, Peter Otten wrote: >> This works just like a < b < c: >> > 3 in [3] and [3] == True >> False > Interesting. I agree with the OP that it is confusing! > > Does this expansion really get invoked every time there is an expression > of th

Re: Weird expression result

2008-08-18 Thread cokofreedom
On Aug 18, 5:57 pm, George Sakkis <[EMAIL PROTECTED]> wrote: > I'm probably missing something obvious but I can't put my finger on > it: > > >>> (3 in [3]) == True > > True > > >>> 3 in ([3] == True) > > Traceback (most recent call last): > File "", line 1, in > TypeError: argument of type 'bool

Re: Weird expression result

2008-08-18 Thread Dan Lenski
On Mon, 18 Aug 2008 18:04:32 +0200, Peter Otten wrote: > This works just like a < b < c: > 3 in [3] and [3] == True > False > > Peter Interesting. I agree with the OP that it is confusing! Does this expansion really get invoked every time there is an expression of the form?? expr1 binar

Re: Weird expression result

2008-08-18 Thread Peter Otten
George Sakkis wrote: > I'm probably missing something obvious but I can't put my finger on > it: > (3 in [3]) == True > True > 3 in ([3] == True) > Traceback (most recent call last): > File "", line 1, in > TypeError: argument of type 'bool' is not iterable > 3 in [3] == True

Weird expression result

2008-08-18 Thread George Sakkis
I'm probably missing something obvious but I can't put my finger on it: >>> (3 in [3]) == True True >>> 3 in ([3] == True) Traceback (most recent call last): File "", line 1, in TypeError: argument of type 'bool' is not iterable >>> 3 in [3] == True False How/why does the last one evaluate t