Is there a better/simpler way to filter blank lines?

Steven D'Aprano steve at REMOVE-THIS-cybersource.com.au
Tue Nov 4 23:41:15 CET 2008


On Tue, 04 Nov 2008 13:27:00 -0800, tmallen wrote:

> I'm parsing some text files, and I want to strip blank lines in the
> process. Is there a simpler way to do this than what I have here?
> 
> lines = filter(lambda line: len(line.strip()) > 0, lines)
> 
> Thomas


lines = filter(lambda line: line.strip(), lines)


-- 
Steven



More information about the Python-list mailing list