Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

The 'is' identity operator checking immutable values caution

0 views
Skip to first unread message

wxPyt...@gmail.com

unread,
May 13, 2008, 6:10:13 AM5/13/08
to
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.

How is with this issue in Python 3.0? Is it fixed? Does Python handle
this things properly now?

casti...@gmail.com

unread,
May 13, 2008, 6:26:11 AM5/13/08
to

Ooo. Timing. Good one. <joins rip on 3.0>

Writer's other wanderings bring Microsoft Research. Who talks to that
on a daily basis?

Marco Mariani

unread,
May 13, 2008, 6:26:13 AM5/13/08
to
wxPyt...@gmail.com wrote:

> We have to avoid the use of the 'is' identity operator with basic,
> immutable values such as numbers and strings.

I'm glad for you. Did you really write checks like "if foo is 27" ?

The point is, you have to learn technologies to use them. It's not like
technologies learn you (not even in soviet Russia)

> How is with this issue in Python 3.0? Is it fixed?

There is nothing to fix.

> Does Python handle this things properly now?

It always did.

Christian Heimes

unread,
May 13, 2008, 6:37:38 AM5/13/08
to pytho...@python.org
wxPyt...@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

casti...@gmail.com

unread,
May 13, 2008, 6:59:56 AM5/13/08
to
On May 13, 5:37 am, Christian Heimes <li...@cheimes.de> wrote:
> wxPytho...@gmail.com schrieb:

I was back on 'handle'. Handle internally, handle right. Gotta be 6
a.m.

Bruno Desthuilliers

unread,
May 13, 2008, 11:59:01 AM5/13/08
to
wxPyt...@gmail.com a écrit :

This is not an issue and is already properly handled. Don't use identity
test when you want an equality test, period.

0 new messages