bearophileh...@lycos.com <bearophileh...@lycos.com> wrote: > Brett Hedges: > > My question is how do I go to a previous line in the file? xreadlines has a > > file.next() statement that gives the next line, and I need a statement that > > gives me the previous line.< > > In modern versions of Python you usually don't need xreadlines, > because files are iterable. > > If your files are small, you can just read all the lines in a list > with open(...).readlines(), and then just use the item of the list > with the n-1 index.
There is also the linecache module http://docs.python.org/library/linecache.html Which may be useful... -- Nick Craig-Wood <n...@craig-wood.com> -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list