Why doesn't deepcopy work on strings ?

Sarat Venugopal sarat_venugopal_news at yahoo.com
Mon Feb 24 06:57:39 EST 2003


>>> s1='monty python'
>>> s2=(s1+'x')[:-1]
>>> s2
'monty python'
>>> id(s1), id(s2)
(15201944, 15097976)

;-)

Sarat

"Tony C" <cappy2112 at yahoo.com> wrote in message
news:8d3e714e.0302231816.741f8691 at posting.google.com...
> 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
>
> thanks






More information about the Python-list mailing list