proposal: another file iterator

Benji York benji at
Sun Jan 15 21:51:07 EST 2006

Jean-Paul Calderone wrote:
 >  When I just want the dumb version, I tend to write this:
 >     for chunk in iter(lambda:, ''): ...
 > Which is only very slightly longer than your version.  I would like it
 > even more if iter() had been written with the impending doom of lambda
 > in mind, so that this would work:
 >     for chunk in iter('',, blocksize): ...
 > But it's a bit late now.

How about this instead (will work in 2.5):

     for chunk in iter(partial(, blocksize), ''): ...

Benji York

More information about the Python-list mailing list