Is it really good?

Cliff Wells LogiplexSoftware at earthlink.net
Tue Jan 7 19:50:38 EST 2003


On Tue, 2003-01-07 at 15:43, Skip Montanaro wrote:
>     Nadav> Can someone explain why python does not raise NameError in the
>     Nadav> first test line b[e]low.
> 
>     >>> 2 == 3 is good
>     0     # ????????????????????????
> 
> Chained operations.  The above expression is effectively
> 
>     (2 == 3) and (3 is good)

This confuses me.  What is the order of operation for '==' and 'is'? 
Even if == is evaluated first, the equivalent would be:

(2 == 3) is good

if 'is' is higher then it becomes

2 == (3 is good)

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

> The first is false, so the second is never evaluated.

That was my first thought, but I can't see how it works.

-- 
Cliff Wells, Software Engineer
Logiplex Corporation (www.logiplex.net)
(503) 978-6726 x308  (800) 735-0555 x308






More information about the Python-list mailing list