Python Success Stories or Nightmares
Grzegorz Adam Hankiewicz
gradha at terra.es
Sun Feb 2 15:42:44 EST 2003
On Sat, Feb 01, 2003 at 03:38:58PM -0000, James Kew wrote:
> > while (line = file.readline()):
> >
> > I still miss that one-liner.
>
> Doesn't
> for line in file: # or file.xreadlines() or file.readlines() in
> earlier Python versions
>
> do the same thing in just as few lines?
It's incredible how many people jump in to point out that it's
possible to rewrite that (no, sorry, file.readlines() might need
more than your available RAM and is not the same), when I just tried
to say that I miss assigning and testing with one statement.
And again, before another round of people start pointing at me,
yes, Python's cookbook receipt 1.9 suggests another way to do that,
like wrapping in a class or using list comprehensions. Thanks in
advance for pointing out this too.
More information about the Python-list
mailing list