How to read lines from end of a file?

Stig Bjorlykke stigb at tihlde.org
Thu Dec 23 09:02:05 EST 1999


"Darrell" <news at dorb.com> writes:

| Maybe maxLen should be sys.maxint by default. Then paranoid or
| performance concerned, can tone it down from there.

This was not exactly what I was looking for:  I want to read the last
lines from a file, one by one, until I find what I'm looking for.

Instead of using your function I could have used 'tail -10 file', but I
don't know where my log entry is in the file, so I have to search
backwards in the file to find it.

Hope this clarifies the situation I have ;)


PS: It seems like the reverse() function does what I want, so I use
that until I find something better.


-- 
Stig Bjørlykke
Linux user



More information about the Python-list mailing list