I know

    with open('foo.txt') as f:
        ...do something...

will close the file automatically when the "with" block ends. 

I also saw codes in a book:

    for line in open('foo.txt'):
        ...do something...

but it didn't mention if the file will be closed automatically or not when the 
"for" block ends. Is there any document talking about this? and how to know if 
a file is in "open" or not?

--Jach Fong

-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to