No need to close file?
Thomas Bartkus
thomasbartkus at comcast.net
Tue Jul 18 16:27:44 EDT 2006
"T" <ty.2006 at yahoo.com> wrote in message
news:1153252214.457508.269880 at 35g2000cwc.googlegroups.com...
> Do I need to close the file in this case? Why or why not?
>
> for line in file('foo', 'r'):
> print line
Are you asking if you can get away without closing it?
Or are you asking if it is a good idea to not close it?
Good programming practice says that if you open it - you close it.
And stay out of trouble ;-)
Thomas Bartkus
More information about the Python-list
mailing list