How can you copy (clone) a string?
Mark Jackson
mjackson at wc.eso.mc.xerox.com
Tue Oct 3 10:52:30 EDT 2000
More information about the Python-list mailing list
Tue Oct 3 10:52:30 EDT 2000
- Previous message (by thread): How can you copy (clone) a string?
- Next message (by thread): How can you copy (clone) a string?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
=?ISO-8859-1?Q?Max_M=F8ller_Rasmussen?= <maxm at normik.dk> writes: > Just use slice: > > a = 'a' > b = a[:] Doesn't work, at least in 1.5.2: >>> a = 'a' >>> b = a[:] >>> a is b 1 The following perversity seems to do the trick unless a = '': >>> c = repr(a)[1:-1] >>> a is c 0 But I am inclined to agree with the eff-bot: If you think you need to do this, it's time to redesign your program. -- Mark Jackson - http://www.alumni.caltech.edu/~mjackson I respect faith, but doubt is what gets you an education. - Wilson Mizner
- Previous message (by thread): How can you copy (clone) a string?
- Next message (by thread): How can you copy (clone) a string?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list