Mutable Strings?

Delaney, Timothy tdelaney at avaya.com
Tue Jun 26 20:29:14 EDT 2001


[ snip request for Java StingBuffer equivalent ]

Try using a character array (not list - although as has been pointed out,
you can use a list and join the elements - that is the standard python
idiom, but an array is closer to a StringBuffer).

import array

s = array.array('c')   # optionally, s = array.array('c', 'initial string')
s.fromstring('abc')
s.fromstring('defg')

print s.tostring()

Tim Delaney




More information about the Python-list mailing list