[Tutor] Closing handles (was valueOf() equivalent)
D-Man
dsh8290@rit.edu
Fri, 22 Dec 2000 00:05:46 -0500
Since python is interpreted, the interpreter provides you with all the
benefits of a smart run-time system. The interpreter will close all
file handles (and I imagine network connections too) before
terminating.
Even if you are working in C, file handles are closed by the system
upon exit. I don't know about the handles on a popen() connection,
though.
In any case it's still good practice to explicitly close all file handles and
network connections before exiting.
HTH,
-D
On Thu, Dec 21, 2000 at 09:39:39PM -0500, Darrell Brogdon wrote:
> Thanks for the help. In working on my code I found I didn't need to do
> this after all. But the suggestions were helpful and provided good insight.
>
> Another unrelated question though: Is there a requirement to close an
> "os.popen()" connection? I've checked the docs and haven't found
> anything. If not then is it safe to assume that Python automatically
> closes these connections when the script ends? I just want to make sure
> I'm not leaving a bunch of open connections in my script.
>