[Keeping tutor in CC] ---------- Forwarded message ---------- Date: Thu, 20 Oct 2005 23:21:13 +0200 From: Tomas Markus <[EMAIL PROTECTED]> To: Danny Yoo <[EMAIL PROTECTED]> Subject: Re: [Tutor] file.read..... Abort Problem
Hi All, 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. The code works when executed from idle but when I run it from command line, I get: File "c:\Apps\PTOOLS\payfiles\editest.py", line 7 if " ^ SyntaxError: EOL while scanning single-quoted string Is there any workaround? Thanks Tom On 20/10/05, Danny Yoo <[EMAIL PROTECTED]> wrote: > > > > I was going to ask why you think regex is a sledgehammer for this one, > > Regex's are more complex because we have to then make sure that none of > the testchars have any special meaning as regular expression > metacharacters. If one of those test chars, for example, contained things > like '-' or '\\', we'd have to know to use re.escape() to be safe about > things. > > Once we know regex's (and have been bitten by forgetting those issues... > *grin*), then these factors aren't so large. > > _______________________________________________ > Tutor maillist - [email protected] > http://mail.python.org/mailman/listinfo/tutor > _______________________________________________ Tutor maillist - [email protected] http://mail.python.org/mailman/listinfo/tutor
