Why doesn't deepcopy work on strings ?

Rene Pijlman reageer.in at de.nieuwsgroep
Mon Feb 24 05:06:53 EST 2003


Gerrit Holl:
>Try: s1[:] to copy a string.

Sure, that will work as well.

>>> s1 = "bla"
>>> s2 = s1[:]
>>> print id(s1), id(s2)
7790840 7790840
>>> print s1, s2
bla bla

See, a copy again :-)

-- 
René Pijlman

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




More information about the Python-list mailing list