stripping blanks

Edward Elliott nobody at 127.0.0.1
Tue May 2 22:50:21 CEST 2006


Scott David Daniels wrote:
> A little better:
> 
>      f = open("test.dat")
>      for line in f:
>          printLine = line.rstrip("\n")
>          if printLine:
>              print printLine

[sys.stdout.write(line) for line in open('test.dat') if line.rstrip('\n')]

Where's my prize?  What do you mean, shorter isn't always better? ;)




More information about the Python-list mailing list