Python Success Stories or Nightmares

Andrew Bennetts andrew-pythonlist at puzzling.org
Sun Feb 2 21:44:41 EST 2003


On Sun, Feb 02, 2003 at 08:26:33PM -0600, Ben Wolfson wrote:
> On Sun, 02 Feb 2003 18:11:53 -0800, Paul Rubin wrote:
> > 
> > How would you write
> > 
> >    while ((c = getc(file)) != EOF)
> >        ...
> > 
> > without missing the one-liner?
> 
> for c in iter(lambda: file.read(1), ''):
>    ...

Ooh!  I didn't realise iter could do that! :)

-Andrew.






More information about the Python-list mailing list