Problem!!

Dave Angel davea at ieee.org
Mon Jul 4 22:26:53 EDT 2011


On 01/-10/-28163 02:59 PM, amir chaouki wrote:
> the problem is when i use the seek function on windows it gives me
> false results other then the results on *ux. the file that i work with
> are very large about 10mb.
>

If you still care about this problem, you should take some of the other 
suggestions to heart;  post some code, state what you expected, and what 
actually happened, and how they're different.

But my crystal ball says you're trying to do a seek on a text file, 
which has restrictions.  Once you've called it a text file, you're 
telling the system to translate cr/lf pairs into lf, which changes the 
apparent size.  So seek has no way to reproduce what reading lines does.


To quote the docs at   http://docs.python.org/library/stdtypes.html :
"If the file is opened in text mode (without 'b'), only offsets returned 
by tell() <http://docs.python.org/library/stdtypes.html#file.tell> are 
legal. Use of other offsets causes undefined behavior."

DaveA
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20110704/7f58dc8b/attachment.html>


More information about the Python-list mailing list