No need to close file?

bearophileHUGS at lycos.com bearophileHUGS at lycos.com
Tue Jul 18 16:08:45 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

Close the file in Jython, but often it's not necessary in CPython.

Bye,
bearophile




More information about the Python-list mailing list