This is for Python 2.6.
I could not figure out why a and b are identical:
>>> a = \"some_string\"
>>> b = \"some_string\"
>>>
Python may or may not automatically intern strings, which determines whether future instances of the string will share a reference.
If it decides to intern a string, then both will refer to the same string instance. If it doesn't, it'll create two separate strings that happen to have the same contents.
In general, you don't need to worry about whether this is happening or not; you usually want to check equality, a == b
, not whether they're the same object, a is b
.