Why doesn't deepcopy work on strings ?

Peter Hansen peter at engcorp.com
Sun Feb 23 21:26:57 EST 2003


Tony C wrote:
> 
> Why doesn't deepcopy() on a string make a deep copy of that string ?
> 
> Would someone explain this ..
> import copy
> s1="monty python"
> s2=copy.deepcopy(s1)
> id(s1)
> 19114192
> id(s2)
> 19114192

Maybe because strings are immutable?  What would be the point of
making a copy unless they could be changed?

-Peter




More information about the Python-list mailing list