Python Success Stories or Nightmares

Geoff Gerrietts geoff at gerrietts.net
Thu Jan 30 18:51:36 EST 2003


Quoting Grzegorz Adam Hankiewicz (gradha at terra.es):
> > What works and doesn't work in Python.
> 
>   while (line = file.readline()):
> 
> I still miss that one-liner.

How about a pythonic substitute?

  for line in file.readlines():

Or, if you're not trapped on 1.5.2 like me:

  for line in file.xreadlines():

-- 
Geoff Gerrietts             "A little sincerity is a dangerous thing, 
geoff @ gerrietts.net        and a great deal of it is absolutely fatal." 
http://www.gerrietts.net/                           --Oscar Wilde





More information about the Python-list mailing list