Anthony Liu wrote:
I am wondering if it is possible to start reading from
the last line of file, and then the last but one up to
the first line.

If you can afford to keep the whole file in memory, than:

lines = open(..).readlines()
print lines[::-1]

Otherwise you can use seek() to random-access file and read chunks,
then extract lines from them and process them.
See http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/120686 for implementation details.


Mike

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to