On 3/5/2011 1:21 PM, tkp...@hotmail.com wrote:
Thanks for the pointer. Yes, it is a text file, but the mystery runs
deeper: I later found that it works perfectly as written when I run it
from IDLE or the Python shell, but it fails reliably when I run it
from PyScripter 2.4.1 (an open source Python IDE)! So I suspect
there's a PyScripter issue lurking in here. I'm next going to try the
solution you propose - use only for legal offsets - and then retry it
under both IDLE and PyScripter. Question: how do I use f.tell() to
identify if an offset is legal or illegal?

I do not believe you can. You have to be at a position and f.tell() will report it.

Note: if a file is utf-8 encoded, and you seek to an arbitrary position in binary mode, it is easy to synchronize by discarding the remainder (if any)of a multibyte char and finding the start of the next char.

--
Terry Jan Reedy

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to