jon vspython wrote: > Hi, > I tried this on a file: > > for line in fileinput.input("myfile",inplace=1): > re.sub(r'LOOP',r'PRUEBALOOP',line)
I'm not sure why you got any output at all. Were you running this in a shell that prints out loop values for you (e.g. IPython)? re.sub returns the modified line. Try import sys sys.stdout.write(re.sub(r'LOOP',r'PRUEBALOOP',line)) I used stdout.write() instead of print because you already have the needed line endings in place. Kent > > and for lines like this: > > PT_WT_INIT: LOOP > > I got this: > > 'PT_WT_INIT: PRUEBALOOP\r\n' > > I also tried without raw strings: > > re.sub('LOOP','PRUEBALOOP',line) > > but I got the same result. > > Any hint? > Thanks, Jon. > > _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor