file.tell() ?

Chris McAvoy mcavoy76 at hotmail.com
Sat Mar 20 19:35:09 EST 2004


Is this a bug? (file is an open text file):

>>> for i in range(0,5):
... 	var = file.next()
... 	file.tell()
... 	
1675L
1675L
1675L
1675L
1675L

I would have thought that it would increase as the position of the
file.

When I use readline, it works as I would expect:

>>> for i in range(0,5):
... 	var = file.readline()
... 	file.tell()
... 	
18L
31L
53L
67L
85L

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?

Thanks,
Chris



More information about the Python-list mailing list