Why doesn't deepcopy work on strings ?

Rene Pijlman reageer.in at de.nieuwsgroep
Mon Feb 24 04:52:57 EST 2003


Tony C:
>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 

You're testing for identity instead of value. I can assure you
that the strings are copies when you print them both :-)

-- 
René Pijlman

Wat wil jij leren?  http://www.leren.nl




More information about the Python-list mailing list