This is for Python 2.6.
I could not figure out why a and b are identical:
>>> a = "some_string"
>>> b = "some_string"
>>> a is b
True
But if there is a space in the string, they are not:
>>> a = "some string"
>>> b = "some string"
>>> a is b
False
If this is normal behavior, could someone please explain what is going on.
Edit: Disclaimer ! This is not being used to check for equality. I actually wanted to explain to someone else that "is" is only to check identity, not equality. And from the documentation I had understood that references created in this way will be different, that a new string will be created each time. The very first example I gave threw me off when I couldn't prove my own point!
Edit: I understand that this is not a bug, and interning was a new concept for me. This seems to be a good explanation.