[EMAIL PROTECTED] wrote: > 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.
yes, this invariably happens me (with PythonWin) if I try to get away without a 'finally' Gerard -- http://mail.python.org/mailman/listinfo/python-list