looping over a big file

Asun Friere afriere at yahoo.co.uk
Wed Jul 6 01:45:07 EDT 2005


Jp Calderone wrote:

>   fileIter = iter(big_file)
>   for line in fileIter:
>       line_after = fileIter.next()
>
>   Don't mix iterating with any other file methods, since it will confuse the buffering scheme.
>

Isn't a file an iterable already?

[GCC 3.3.3 20040412 (Red Hat Linux 3.3.3-7)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> foo = open('sample.txt')
>>> bar = iter(foo)
>>> bar is foo
True




More information about the Python-list mailing list