How to do this in Python?

Jim Garrison jhg at
Wed Mar 18 16:07:49 CET 2009

Luis Zarrabeitia wrote:
> On Tuesday 17 March 2009 06:04:36 pm Jim Garrison wrote:
> with open(filename, "rb") as f:
>     for buf in iter(lambda:,''):
>         do_something(buff)

This is the most pythonic solution yet.

Thanks to all the responders who took time to ponder this seemingly
trivial question.  I learned a lot about the Python mind-set.

More information about the Python-list mailing list