Reading a text file backwards

Graham Fawcett graham.fawcett at gmail.com
Thu Sep 30 20:41:14 EDT 2004


It's just shifting the burden perhaps, but if you're on a Unix system
you should be able to use tac(1) to reverse your file a bit faster:

import os
for line in os.popen('tac myfile.txt'):
#do something with the line




More information about the Python-list mailing list