copying a string???
aahz at pythoncraft.com
Thu Aug 22 16:57:09 CEST 2002
In article <3D64B97B.3BFDC676 at mill.co.uk>,
Joe Connellan <joec at mill.co.uk> wrote:
>I have a function that alters the value of a string (written in C). (is
Yes. (Just to hammer the point in.)
>anyone know how I can really copy the string? or am I missing something
If you absolutely, positively, need a copy of a string, do this:
s2 = s1[:1] + s1[1:]
However, I should add the caveat that nothing in Python's language spec
guarantees that this will return a copy; it's simply deeply embedded in
the current implementation.
Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/
Project Vote Smart: http://www.vote-smart.org/
More information about the Python-list