Seemingly odd 'is' comparison.

Erik Max Francis max at alcyone.com
Mon Feb 18 15:05:55 EST 2008


Tobiah wrote:

>>>> print float(3.0) is float(3.0)
> True
>>>> print float(3.0 * 1.0) is float(3.0)
> False
>>>>     

It's implementation dependent what values these expressions will take.

If you're trying to test equality, use `==`, not `is`.

-- 
Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/
  San Jose, CA, USA && 37 18 N 121 57 W && AIM, Y!M erikmaxfrancis
   There is nothing more incomprehensible than a wrangle among
    astronomers. -- H.L. Mencken



More information about the Python-list mailing list