file.tell() ?

Erik Max Francis max at alcyone.com
Sat Mar 20 19:45:22 EST 2004


Chris McAvoy wrote:

> The reason I ask is, I have a very large file to parse line by line.
> I thought I'd try and use an iterator, but it looks like the iterator
> is really reading the entire file into memory before it starts
> iterating.  So my best option is still to use file.readline().
> 
> Am I understanding this correctly?  Am I using the iterator
> incorrectly?

The iterating methods of file input tend to buffer input, so calling
things like .tell or additionally trying to read data manually is not
going to work properly.

If it's important to you that you have total control over the current
"read pointer" in the file, call .readline manually.  If you don't care
and just want to read through everything, use the iterators.

-- 
 __ Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/
/  \ San Jose, CA, USA && 37 20 N 121 53 W && &tSftDotIotE
\__/ The average dog is a nicer person than the average person.
    -- Andrew A. Rooney



More information about the Python-list mailing list