[Tutor] When are strings interned?
Angus Rodgers
angusr at bigfoot.com
Wed Jul 1 17:44:36 CEST 2009
Hello, world!
This is my first post to the Tutor list (although I've already
posted to comp.lang.python a couple of times).
I'm currently reading Chapter 4 of Wesley Chun's book, "Core
Python Programming" (2nd ed.).
I find this, in Python 2.5.4, on my Win98SE system (using IDLE):
>>> n = "colourless"
>>> o = "colourless"
>>> n == o
True
>>> n is o
True
>>> p = "green ideas"
>>> q = "green ideas"
>>> p == q
True
>>> p is q
False
Why the difference?
--
Angus Rodgers
More information about the Tutor
mailing list