Will file be closed automatically in a "for ... in open..." statement?

jfong at ms4.hinet.net jfong at ms4.hinet.net
Tue Feb 16 23:04:14 EST 2016


Thanks for these detailed explanation. Both statements will close file automatically sooner or later and, when considering the exceptions, "with" is better. Hope my understanding is right.

But, just curious, how do you know the "for" will do it? I can't find any document about it from every sources I know. Very depressed:-(

--Jach



More information about the Python-list mailing list