Re: String manipulation questions

2008-04-09 Thread goldtech
snip... > >for counter, line in enumerate(fileIN): >newline = line.replace(oldstring, newstring) >if newline != line: >print 'match at line', counter+1 >fileOUT.write(newline) "enumerate" - haven't seen that before. Nice! Thanks -- http://mail.python.org/m

Re: String manipulation questions

2008-04-09 Thread Duncan Booth
goldtech <[EMAIL PROTECTED]> wrote: > Question1: The replace method - If a string does not have the target > replacement "newstring", then newline equals oldstring? Ie. oldstring > is not changed in any way? Seems to be what I observe but just want to > confirm this. Yes. > > Question2: I'm us

String manipulation questions

2008-04-09 Thread goldtech
Hi, Replacing strings in a text (likely an XML) file. Some newbie questions... ... while line: counter=counter+1 if line.find(newstring) != -1: print 'match at line'+str(counter) newline = line.replace(oldstring, newstring) fileOUT.write(newline) line=fileIN.readline()