[Tutor] For loop question

Kent Johnson kent37 at tds.net
Wed May 10 17:02:47 CEST 2006


w chun wrote:
> Kent Johnson wrote:
>> For short Python scripts I usually allow the runtime to close the file.
>> For longer programs and anything written in Jython (which has different
>> garbage collection behaviour) I usually use an explicit close().
> 
> i'm still not comfortable without doing my own explicit close(), esp.
> for writing to files... maybe i'm just used to malloc/new-free pairs
> like i am with open-close, although on the other hand, getting rid of
> another line of code is tempting -- so i will actually do this with a
> short piece of code that is read-only.

Yes, for writing files I always use an explicit close(), thanks for the 
correction!

Kent



More information about the Tutor mailing list