Re: 3>0 is True

2010-09-15 Thread Yingjie Lan
> From: Jon Siddle > Subject: Re: 3>0 is True > To: python-list@python.org > Date: Wednesday, September 15, 2010, 5:04 PM >   As others have said, it's not > a matter of precendence. Using the > compiler module > you can see how python actually parses this: >

Re: 3>0 is True

2010-09-15 Thread Jon Siddle
As others have said, it's not a matter of precendence. Using the compiler module you can see how python actually parses this: 3 > (0 is True) Compare(Const(3), [('>', Compare(Const(0), [('is', Name('True'))]))]) No great surprise there. 3 > 0 is True Compare(Const(3), [('>', Const(0)), ('is',

Re: 3>0 is True

2010-09-15 Thread Michael Ricordeau
Not really true for ">" and "is" : http://docs.python.org/reference/expressions.html#evaluation-order Operator ">" and operator "is" are in the same precedence but in group Comparisons : "Operators in the same box group left to right (except for comparisons, including tests, which all have t

Re: 3>0 is True

2010-09-15 Thread Mel
Yingjie Lan wrote: > I am not sure how to interprete this, in the interactive mode: > 3>0 is True > False (3>0) is True > True 3> (0 is True) > True > > Why did I get the first 'False'? I'm a little confused. > > Thanks in advance for anybody who shed some light on this. This loo

Re: 3>0 is True

2010-09-15 Thread Jussi Piitulainen
Yingjie Lan writes: > I am not sure how to interprete this, in the interactive mode: > > >>> 3>0 is True > False > >>> (3>0) is True > True > >>> 3> (0 is True) > True > > Why did I get the first 'False'? I'm a little confused. It is interpreted as equivalent to this: >>> 3 > 0 and 0 is Tr

Re: 3>0 is True

2010-09-15 Thread Peter Otten
Yingjie Lan wrote: > I am not sure how to interprete this, in the interactive mode: > 3>0 is True > False (3>0) is True > True 3> (0 is True) > True > > Why did I get the first 'False'? I'm a little confused. http://docs.python.org/reference/expressions.html#notin """ Unlike C,

Re: 3>0 is True

2010-09-15 Thread Michael Ricordeau
Because "is" operator take precedence on ">" operator . Le Wed, 15 Sep 2010 05:34:06 -0700 (PDT), Yingjie Lan a écrit : > Hi, > > I am not sure how to interprete this, in the interactive mode: > > >>> 3>0 is True > False > >>> (3>0) is True > True > >>> 3> (0 is True) > True > > Why did I ge