[Tutor] What is missing?

Kirby Urner urnerk@qwest.net
Mon, 04 Feb 2002 08:35:08 -0800

At 03:09 PM 2/4/2002 +0100, Remco Gerlich wrote:

>Closing them may look good and make your program a little more
>robust, but isn't usually necessary in Python. The moment that
>inFile refers to a new open file, the old file object is
>destroyed, and closed. That also happens when the programs

Yeah, I recommend explicitly closing in most cases, and
maybe also putting the close() in a finally block, with
any problematic code under development in a try block.
That way, you can debug in the shell without worrying
whether a crash in the script has caused a file to be
left open.

People like me, who rarely execute scripts, but often
open modules and use them as a grab bag to be executed
in shell mode, especially need to close files explictly.