first, second, etc line of text file

Bjoern Schliessmann usenet-mail-0306.20.chr0n0ss at
Wed Jul 25 23:07:18 CEST 2007

Grant Edwards wrote:
> On 2007-07-25, Jeff McNeil <jeff at> wrote:
>> Depending on the size of your file, you can just use
>> file.readlines. Note that file.readlines is going to read the
>> entire file into memory, so don't use it on your plain-text
>> version of War and Peace.
> I don't think that would actually be a problem for any recent
> machine.
> The Project Gutenberg version of W&P is 3.1MB of text in 67403
> lines.  I just did an f.readlines() on it and it was pretty
> much instantaneous, and the python interpreter instance that
> contains that list of 67403 lines is using a bit less than 8MB
> of RAM. 




BOFH excuse #335:

the AA battery in the wallclock sends magnetic interference

More information about the Python-list mailing list