> From: Tomas Markus <[EMAIL PROTECTED]> > Just to let you know my ressults (+ one tiny question :-): > I did a bit of investigation and narrowed the "invalid" characters group to > jus one the hex 1a. My code now looks quite small: > > fpath = 'c:\\pytemp\\bafir550.edi' > fl = file(fpath, 'rb') > print 'Checking file %s' % fpath > x=0 > for line in fl.readlines(): > x=x+1 > if "" in line: > print 'Not allowed chars at line %s --- %s' % (x,line), > print "The check finished on line %s which was %s" % (x,line) > > The only proble is tha in the if clause there actually is the hex 1a > character.
You don't have to type an actual 1a character to get it into a Python string. You can use special character escapes instead. To put a hex value into a string, use the escape \x followed by the two hex digits. So your test can be if "\x1a" in line: This way there is no actual 1a character in your program, but it will still do what you want. Kent _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor