On 8/12/2010 10:52 PM, Matt Schinckel wrote:
a = "hello"
b = "hello"
a is b
True
Ooh, that looks dangerous.
Only for mutable objects
Are they the same object?
Yes.
a += "o"
This is equivalent to a = a+"o". The expression creates a new object.
The assignment binds the object to name 'a'.
> (Python does not make two copies of small strings until it needs to).
Python never copies *any* object until you ask it to. It never made a
copy of the original 'a' here either. It combined the values of two
string objects to make a new string object with a new value.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list