file.seek misbehaving?
Gordon McMillan
gmcm at hypernet.com
Fri Jun 2 17:14:12 EDT 2000
cheesecake <vigenereNOviSPAM at leland.stanford.edu.invalid>
wrote:
>
>I've run into a problem that is perhaps not a Python-specific
>bug. I was processing some log files using Python, when I
>noticed some mysterious bugs in certain files. I tracked down
>the problem to the seek method misbehaving.
[big snip]
Nope, it's not Python's problem. You can't reliably seek on a file
opened in text mode (on Windows). You'll get the same (bad) results
working in C.
If I were you, I'd open the file in binary mode (so seek and tell work
properly) and deal with line endings explicitly.
- Gordon
More information about the Python-list
mailing list