How to modify a string in place?

Andrew M. Kuchling akuchlin at cnri.reston.va.us
Fri May 14 12:38:09 EDT 1999


John Powers writes:
>I would like to modify the string in place. Any ideas?

	Use the array module:

>>> import array
>>> a = array.array('c', 'hello world')
>>> print a
array('c', 'hello world')
>>> a[0] = 'y' ; print a
array('c', 'yello world')

-- 
A.M. Kuchling			http://starship.python.net/crew/amk/
It is by the goodness of God that in our country we have those three
unspeakably precious things: freedom of speech, freedom of conscience, and the
prudence never to practise either of them.
    -- Mark Twain





More information about the Python-list mailing list