Andrew Robert wrote: > The python method inserts extra blank lines after each hex value line. > Does anyone know why this might be? > > Is the print statement inserting a artificial new line character?
Yes, this is a feature of print, it always inserts a newline. To avoid this, use sys.stdout.write() instead of print: for line i open(r'e:\pycode\sigh.txt','rb'): line = re.sub(r'([^\w\s])', lambda s: '%%%2X' % ord(s.group()), line) sys.stdout.write(line) Kent > > If so, how cam I remove that? > > > The python code I am using is: > > > > import re,sys > > for line i open(r'e:\pycode\sigh.txt','rb'): > print re.sub(r'([^\w\s])', lambda s: '%%%2X' % ord(s.group()), line) _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor