[Tutor] Discrepancy

Isr Gish isrgish at fastem.com
Tue Mar 23 00:40:52 EST 2004


Hi Kiran

kiran at mhowlinux.org wrote:
   >hi
   >
   >what is the problem
   >
   >> x =1
   >>x   is   1
   >1
   >>
   >> (1 is 1)
   >1

This 1 here meens True (in 2.3  it actually returns True instead of 1)

   >>
   >>x is (1 is 1)
   >0

Therefore x which is the number 1 is not the same as True

In other words "is" does not do the same as an "==" test.

>>> (1 is 1)
True
>>> x = 1
>>> x is (1 is 1)
False
>>> x == (1 is 1)
True


   >
   >once i set x=1
   >x is 1   returns true(1)
   >(1 is 1) returns true(1)
   >
   >whereas
   > x is (1 is 1)
   >returns 0
   >
   >
   >
   >Python Version 2.2.3
   >
   >
   >
   >

All the best

Isr Gish




More information about the Tutor mailing list