[Tutor] Re: file filter
Wed, 26 Dec 2001 17:02:42 -0000
> i can get the copy part. It is just the filter part i am
> confused about. You see, if the line begins with 'c' or ';' i
> want to ignore the whole line.
> def boksa(infilename, outfilename):
> for aLine in infile.xreadlines() :
if aLine not in ';c' #sequence of tested chars
> f.write( aLine )
Should do it.
You could do more sophisticated things by using the
string.find() function or the re module. But the principle
is the same, just test the line before writing it.