> 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 True
Compare(Const(3), [('>', Const(0)), ('is',
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
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
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
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,
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