A few beginning questions

richardc richardc at hmgcc.gov.uk
Tue Jul 15 14:41:23 CEST 2003

"Duncan Booth" <duncan at NOSPAMrcp.co.uk> wrote in message
> If the file isn't too large you can call the readlines() method and simply
> reverse the result as above. You may find this incovenient for very large
> files though.

It may well be

> I can't think of many cases where I would want to read a
> whole file in reverse, if all you want is the last few lines of a massive
> file then just seek near the end before reading the remainder and reverse
> the resulting list of lines.

This is exactly what Im doing, what Im actually doing is seeking to 1024
bytes from the end, then looking for the string
'startref\r\n<number>\r\n%%EOF' where <number> is an integer in decimal

I wanted to scan the lines backwards until I found %%EOF (as its likley to
be the last line) and do it that way.  I might do that or might use a regex
and just let that find it.



More information about the Python-list mailing list