I'm reading "python cookbook" From it I know that some operations will modified the object assigning to a name. Thus may cause problem. Such as:
a = [1,2,3]
b = a
b.append(4)
print a, b
[1,2,3,4] [1,2,3,4]
and on this situation, I should:
import copy
b = copy.copy(a)
b.append(5)
print a, b
[1,2,3,4] [1,2,3,4,5]
But if I just assigning a different object to a name, nothing happened, like:
a = 'x'
b = a
a = 0
print a,b
0 x
But a question raised in my head, which are objects that can be modified directly in python, and with what function I can modified them? (So that when I met places which need to use such functions, I know that it's time to use copy)