Brett, I'm not sure what exactly you're trying to do, but you can keep track of line numbers using itertools.
import itertools for lineIndex, line in itertools.izip(itertools.count(1), open('text.txt')): print lineIndex, line Here is sample code for breaking on a word and returning the previous line def breakOnWord(filePath, word): previousLine = '' for line in open(filePath): if word in line: return previousLine previousLine = line On Fri, Feb 27, 2009 at 11:43 AM, <bearophileh...@lycos.com> wrote: > Brett Hedges: >> How would I keep track of the absolute position of the lines? > > You may have to do all things manually (tell, seek and looking for > newlines manually, iterating chars), that's why I have said it's not > handy. The other solutions are simpler. > > Bye, > bearophile > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list