[Tutor] Omitting lines matching a list of strings from a file
galaxywatcher at gmail.com
galaxywatcher at gmail.com
Thu Feb 25 14:42:21 CET 2010
> But I would do this with a list comprehension or generator
> expression (depending on your Python version):
>
>
> lines = [line for line in infile if line[146:148] not in omit_states]
> print '\n'.join(lines)
That's very helpful. Thanks. One formatting detail: there is a blank
line after each line printed, how do I ged rid of the extra blank lines?
More information about the Tutor
mailing list