How to close all python-opened file identifiers?

Tim Roberts timr at
Sun Jul 27 06:20:37 CEST 2008

BAnderton <blake.anderton at> wrote:
>Question:  Is there a way in Python to determine what all file
>identifiers have been opened by Python, and to close them all?

No.  You are expected to be able to track this yourself.  Python doesn't
open any files that you didn't request.

>Extra info on this specific problem:  In my program, python (through
>subprocess) launched a text editor on a text file, and I can't seem to
>save the text file through that editor (I get a "this document is in
>use by another application and cannot be accessed" error from the
>editor [wordpad on winXp]).  The text file in question is modified by
>my program prior to its loading into the launched editor.  Although I
>can't find unmatched "open" and "fid.close()" statements, I'd like to
>implement a check for open file identifiers before launching the

If you want to post some code, perhaps we can find something.
Tim Roberts, timr at
Providenza & Boekelheide, Inc.

More information about the Python-list mailing list