Basic file operation questions

Caleb Hattingh caleb1 at telkomsa.net
Thu Feb 3 23:06:38 EST 2005


Peter

> Yes, you can even write
>
> f = open("data.txt")
> for line in f:
>     # do stuff with line
> f.close()
>
> This has the additional benefit of not slurping in the entire file at  
> once.

Is there disk access on every iteration?   I'm guessing yes?  It shouldn't  
be an issue in the vast majority of cases, but I'm naturally curious :)

thx
Caleb





More information about the Python-list mailing list