Re: Modify one character in a string

2006-05-26 Thread Scott David Daniels
Marc 'BlackJack' Rintsch wrote: > In <[EMAIL PROTECTED]>, Roy Smith wrote: > >>> Also, how do I do this when dealing with a file ; which file mode >>> should I use and what function should I use to modify a single >>> character once in that file mode? >> This is a much more complicated question, b

Re: Modify one character in a string

2006-05-26 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Roy Smith wrote: >> Also, how do I do this when dealing with a file ; which file mode >> should I use and what function should I use to modify a single >> character once in that file mode? > > This is a much more complicated question, because it depends on the details > o

Re: Modify one character in a string

2006-05-25 Thread Paul Rubin
Larry Bates <[EMAIL PROTECTED]> writes: > IMHO the most elegant method is something like: > > def switchchar(srcstring, position, character): > b=list(srcstring) > b[2]=character > return ''.join(b) If the strings or large or you're doing it a lot, the array module is likely more effi

Re: Modify one character in a string

2006-05-25 Thread Larry Bates
mp wrote: > X-No-Archive > How do I go about modifying one character in a string elegantly? > In other words, I want a function that will change '' to 'aaza', > given the index 2 of the character in the string. > > Also, how do I do this when dealing with a file ; which file mode > should I us

Re: Modify one character in a string

2006-05-25 Thread Roy Smith
"mp" <[EMAIL PROTECTED]> wrote: > X-No-Archive > How do I go about modifying one character in a string elegantly? > In other words, I want a function that will change '' to 'aaza', > given the index 2 of the character in the string. Strings are immutable, so you can't change a string. The be

Re: Modify one character in a string

2006-05-25 Thread keirr
mp wrote: > X-No-Archive > How do I go about modifying one character in a string elegantly? > In other words, I want a function that will change '' to 'aaza', > given the index 2 of the character in the string. > > Also, how do I do this when dealing with a file ; which file mode > should I us

Re: Modify one character in a string

2006-05-24 Thread Paul Rubin
"mp" <[EMAIL PROTECTED]> writes: > How do I go about modifying one character in a string elegantly? > In other words, I want a function that will change '' to 'aaza', > given the index 2 of the character in the string. Ehh, there are various ways, all ugly. x = '' y = x[:2] + 'z' + x

Modify one character in a string

2006-05-24 Thread mp
X-No-Archive How do I go about modifying one character in a string elegantly? In other words, I want a function that will change '' to 'aaza', given the index 2 of the character in the string. Also, how do I do this when dealing with a file ; which file mode should I use and what function shou