Is it really good?

Tim Peters tim.one at comcast.net
Tue Jan 7 20:19:39 EST 2003


[Skip Montanaro]
>>     >>> 2 == 3 is good
>> ...
>> Chained operations.  The above expression is effectively
>>
>>     (2 == 3) and (3 is good)
>

[Cliff Wells]
> This confuses me.  What is the order of operation for '==' and 'is'?

Life will be simpler if you just believe Skip <wink>.  Just as

    1 <= i <= 10

*means*

    (1 <= i) and (i <= 10)

in Python, same thing if you substitute any other comparison operators for
"<=".  "==" and "is" are two other comparison operators.

> ...
> How can (2 == 3) and (3 is good) be a possible equivalence?

The compiler goes out of its way to make it so, as it does for all chained
comparisons.  See your friendly Language Reference Manual for details
(although there's not more to it than what's already been said).






More information about the Python-list mailing list