The 'is' identity operator checking immutable values caution

W

wxPythoner

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?
 
C

castironpi

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?

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

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

Marco Mariani

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.
 
C

Christian Heimes

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
 
C

castironpi

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

Christian

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

Bruno Desthuilliers

(e-mail address removed) a écrit :
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?

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top