The 'is' identity operator checking immutable values caution

Christian Heimes lists at cheimes.de
Tue May 13 06:37:38 EDT 2008


wxPythoner at gmail.com schrieb:
> We have to avoid the use of the 'is' identity operator with basic,
> immutable values such as numbers and strings. The result is
> unpredictable because of the way Python handles these objects
> internally.

You are confusing immutable objects with singletons. Never use "is" with
strings and numbers.

Christian




More information about the Python-list mailing list