473,320 Members | 1,572 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

The 'is' identity operator checking immutable values caution

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?
Jun 27 '08 #1
5 904
On May 13, 5:10*am, wxPytho...@gmail.com wrote:
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?
Jun 27 '08 #2
wx********@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.
Jun 27 '08 #3
wx********@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

Jun 27 '08 #4
On May 13, 5:37*am, Christian Heimes <li...@cheimes.dewrote:
wxPytho...@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
I was back on 'handle'. Handle internally, handle right. Gotta be 6
a.m.
Jun 27 '08 #5
wx********@gmail.com 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.
Jun 27 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

33
by: Axel Boldt | last post by:
Hello, is there a rationale for the following behavior: >>> a = (1,2) >>> b = (1,2) >>> a is b False >>> a = "12" >>> b = "12"
161
by: KraftDiner | last post by:
I was under the assumption that everything in python was a refrence... so if I code this: lst = for i in lst: if i==2: i = 4 print lst I though the contents of lst would be modified.....
37
by: spam.noam | last post by:
Hello, Guido has decided, in python-dev, that in Py3K the id-based order comparisons will be dropped. This means that, for example, "{} < " will raise a TypeError instead of the current...
17
by: nicolas.hilaire | last post by:
Hi all, i've read this article http://msdn2.microsoft.com/en-us/library/85af44e9.aspx who first interest me much. I've translated it to use generic instead of template : generic < typename ...
669
by: Xah Lee | last post by:
in March, i posted a essay “What is Expressiveness in a Computer Language”, archived at: http://xahlee.org/perl-python/what_is_expresiveness.html I was informed then that there is a academic...
4
by: Mike Duffy | last post by:
I just recently realized that the comparison operator "is" actually works for comparing numeric values. Now, I know that its intended use is for testing object identity, but I have used it for a...
12
by: John Henry | last post by:
Hi list, Just to make sure I understand this. Since there is no "pointer" type in Python, I like to know how I do that. For instance, if I do: ...some_huge_list is a huge list...
1
by: miller.brettm | last post by:
Hello, I'm getting the following error message when I try add a row using a Stored Procedure. "The identity range managed by replication is full and must be updated by a replication agent". ...
7
by: elnoire | last post by:
Greetings! I've just started learning python, so this is probably one of those obvious questions newbies ask. Is there any way in python to check if a text file is blank? What I've tried to...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.