Python Help ...
Bill Campbell
linux-sxs
Wed Mar 28 13:18:10 PDT 2007
On Wed, Mar 28, 2007, Ben Duncan wrote:
>But, I need to be able to manipulate the array with values
>latter on. Since strings are immutable, I do not think I can
>do this.
This is really fairly easy, and probably more efficient than
having to deal with the subscripting
# to replace the ith character in a table of strings using an
# intermediate value to make typing easier:
s = stringTable[row]
stringTable[row] = s[:i] + newchar + s[i+1:]
Or as a function being careful to deal with a string longer
than one character long.
def setChar(table, c, i, j):
s = table[j]
table[j] = s[:i] + c[0] + s[i+1:]
Bill
--
INTERNET: bill at Celestial.COM Bill Campbell; Celestial Software LLC
URL: http://www.celestial.com/ PO Box 820; 6641 E. Mercer Way
FAX: (206) 232-9186 Mercer Island, WA 98040-0820; (206) 236-1676
``Never chastise a Windows user...just smile at them kindly as you would a
disadvantaged child.'' WBM
More information about the Linux-users
mailing list