No need to close file?

Jarek Zgoda jzgoda at o2.usun.pl
Tue Jul 18 16:16:03 EDT 2006


T napisał(a):

> Do I need to close the file in this case?  Why or why not?
> 
> for line in file('foo', 'r'):
>   print line

No, if you only read from the file.

But anyway, closing file object is considered good practice in many
documents I found, no matter what you do with it.

-- 
Jarek Zgoda
http://jpa.berlios.de/



More information about the Python-list mailing list