<br><br><div class="gmail_quote">On Wed, Jul 1, 2009 at 4:44 PM, Angus Rodgers <span dir="ltr"><<a href="mailto:angusr@bigfoot.com">angusr@bigfoot.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hello, world!<br>
<br>
This is my first post to the Tutor list (although I've already<br>
posted to comp.lang.python a couple of times).<br>
<br>
I'm currently reading Chapter 4 of Wesley Chun's book, "Core<br>
Python Programming" (2nd ed.).<br>
<br>
I find this, in Python 2.5.4, on my Win98SE system (using IDLE):<br>
<br>
>>> n = "colourless"<br>
>>> o = "colourless"<br>
>>> n == o<br>
True<br>
>>> n is o<br>
True<br>
>>> p = "green ideas"<br>
>>> q = "green ideas"<br>
>>> p == q<br>
True<br>
>>> p is q<br>
False<br>
<br>
Why the difference?<br>
<font color="#888888">--<br><br>
</font></blockquote></div><br><br>IIRC, in cPython (the "defaul" python available from <a href="http://python.org">python.org</a>), there is an optimization done for strings (and I think integers) below a certain size. This is an implementation detail, and could be different in (for instance) Jython.<br>