Seemingly odd 'is' comparison.

Christian Heimes lists at cheimes.de
Mon Feb 18 08:11:53 EST 2008


Tobiah wrote:
>>>> print float(3.0) is float(3.0)
> True
>>>> print float(3.0 * 1.0) is float(3.0)
> False
>>>>     

Thumb rule: Never compare strings, numbers or tuples with "is". Only
compare an object with a singleton like a type or None. "is" is not a
comparison operator.

Christian




More information about the Python-list mailing list