file object: seek and close?

Shu-Hsien Sheu sheu at bu.edu
Thu Sep 18 12:15:49 EDT 2003


Hi,

Does the seek method would close the file object after using a for loop?
My program looks like this:

f = open('somefile', 'r')
for lines in f:
    some operations
f.seek(0)

for lines in f:
    other operations

Python gave me an IOErros saying that the file object is already closed. 
I am now opening the file again under another file object.

Am I doing something wrong or it's a bug?
Thanks!

-shuhsien






More information about the Python-list mailing list