(1) Please do not top post in comp.lang.python, it violates conventions.
Brett Hedges (should have written):
> bearophile wrote: ...
You can also keep track of the absolute position of the lines in the file, etc, or step
>> back looking for newlines, etc, but it's not handy....
How would I keep track of the absolute position of the lines?
> I have tried to use the files.seek() command with the files.tell()
> command and it does not seem to work. The files.tell() command seems
> to give me a number but when I use the files.next() command with
> xreadlines it does not change the line number the next time I use
> files.tell().
The answer to your question depends on what version of Python you are
running. Give python version and platform to any question when you
don't _know_ they are irrelevant.
If you want an answer without any other input, try this:
The simplest way to solve this for the moment is (re)defining
xreadlines:
def xreadlines(source):
for line in iter(src.readline, ''):
yield line
--Scott David Daniels
[email protected]
--
http://mail.python.org/mailman/listinfo/python-list