How to read lines from end of a file?

Paul Jackson pj at sgi.com
Thu Dec 23 18:25:50 EST 1999


|> I want to read the lastlines from a file, one ?
|> by one, until I find what I'm looking for.

|> It seems like the reverse() function does what I want

I'd be tempted to reverse the last big (100 Kbytes?) chunk,
not the entire file.  If the file were huge, I might
rather risk missing the desired line than risk blowing
out my memory to the swap device.

All depends on what you're trying to do ...

-- 

=======================================================================
I won't rest till it's the best ...	   Software Production Engineer
Paul Jackson (pj at sgi.com; pj at usa.net) 3x1373 http://sam.engr.sgi.com/pj



More information about the Python-list mailing list