> 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:
>
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 T
t for comparisons,
including tests, which all have the same precedence and chain from left to
right — see section Comparisons"
The important words here are :
"all have the SAME PRECEDENCE and chain from left to right"
See also :
http://docs.python.org/reference/exp
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 littl
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 l
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
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
> >>>
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 get the first 'False'? I'm a little confused.
Thanks in advance for anybody who shed some ligh