[Python-3000] Reverse file iteration patch updated

Mark Russell mark.russell at zen.co.uk
Sun Dec 9 22:42:34 CET 2007


I posted a patch (http://bugs.python.org/issue1677872) a while ago to  
add support for reverse iteration through text files - i.e. making  
this work:

      for line in reversed(open(path)):
          print line

It steps through the file backwards a line at a time, without reading  
the entire file contents first - useful for scanning backwards though  
big log files for example.

Christian Heimes commented that there's a reasonable chance of it  
being accepted, so I've updated the patch to work against the current  
source, as well as adding unit tests and documentation.

Mark Russell


More information about the Python-3000 mailing list