is and == (is not other_thread)

Greg Ewing greg at cosc.canterbury.ac.nz
Thu Mar 1 21:18:46 EST 2001


Robin Thomas wrote:
> 
> String literals are "interned" by Python, so that it uses a single string
> object for every unique string literals it finds in the code.

Only for strings which happen to look like identifiers, though:

>>> a = "asdf"
>>> b = "asdf"
>>> a is b
1
>>> c = "!@#$"
>>> d = "!@#$"
>>> c is d
0

-- 
Greg Ewing, Computer Science Dept, University of Canterbury,	  
Christchurch, New Zealand
To get my email address, please visit my web page:	  
http://www.cosc.canterbury.ac.nz/~greg



More information about the Python-list mailing list