Larry Bates <[EMAIL PROTECTED]> writes:

> [EMAIL PROTECTED] wrote:
> > xlines = (line for line in open(filename) if line.strip())
> 
> Of if you want to filter/loop at the same time, or if you don't want
> all the lines in memory at the same time

The above implementation creates a generator; so it, too, won't need
to load all the lines in memory at the same time

-- 
 \            “Program testing can be a very effective way to show the |
  `\        presence of bugs, but is hopelessly inadequate for showing |
_o__)                              their absence.” —Edsger W. Dijkstra |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to