No need to close file?
mensanator at aol.com
mensanator at aol.com
Tue Jul 18 16:53:07 EDT 2006
T wrote:
> Do I need to close the file in this case? Why or why not?
>
> for line in file('foo', 'r'):
> print line
I was running a program in IDLE that opened a file for
reading and forgot to add the close.
The program ran and terminated normally.
But when I tried to open it from Windows Explorer,
I got the message that it was still in use. Had to close
IDLE to release it. That wouldn't have happened if I had
closed it from within the program.
More information about the Python-list
mailing list