eof?

Mikael Olofsson mikael at isy.liu.se
Wed Aug 15 08:17:30 EDT 2001


On 15-Aug-2001 Dietmar Lang wrote:
 > >     for line in fh.xreadlines():
 > >         process(line)
 >  
 >  Is xreadlines something I missed or is it a misspelled readlines?
 >  Because as far as I know readlines reads in the whole file into a list
 >  containing the lines, which might not be so practical if the file is
 >  waay big?

That is exacly the situation that xreadlines is for. It does not read
the whole file into memoryas readlines do, but serves the lines of the 
file one by one, with the same syntax as readlines. Compare this to 
range and xrange. Others can give a more detailed description.

/Mikael

-----------------------------------------------------------------------
E-Mail:  Mikael Olofsson <mikael at isy.liu.se>
WWW:     http://www.dtr.isy.liu.se/dtr/staff/mikael               
Phone:   +46 - (0)13 - 28 1343
Telefax: +46 - (0)13 - 28 1339
Date:    15-Aug-2001
Time:    14:14:01

         /"\
         \ /     ASCII Ribbon Campaign
          X      Against HTML Mail
         / \

This message was sent by XF-Mail.
-----------------------------------------------------------------------
Linköpings kammarkör: www.kammarkoren.com




More information about the Python-list mailing list