stripping blanks

Scott David Daniels scott.daniels at acm.org
Tue May 2 16:05:20 EDT 2006


seeker wrote:

> Last suggestion I made was bad. Here is the new one. Hopefully thats 
> correct.
> 
> f = open("test.dat")
>  for line in f:
>     printLine = line.rstrip("\n")
>     if not printLine:
>             continue
>     print printLine

A little better:

     f = open("test.dat")
     for line in f:
         printLine = line.rstrip("\n")
         if printLine:
             print printLine

--Scott David Daniels
scott.daniels at acm.org



More information about the Python-list mailing list