How can you copy (clone) a string?

Peter Schneider-Kamp peter at schneider-kamp.de
Tue Oct 3 11:12:48 EDT 2000


If you know it is not empty:

>>> a = "abcd"
>>> b = a[:1] + a[1:]
>>> id(a)
21765696
>>> id(b)
21763648
>>> a is b
0
>>> a == b
1 

Peter.Rupp at ual.com schrieb:
> 
> All,
> I have a bonafide need to create copies of strings in a python program




More information about the Python-list mailing list