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
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
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()