(newbie) class with a single instance ?!

Fredrik Lundh fredrik at pythonware.com
Fri Dec 15 14:50:49 EST 2006


Andrea Tomadin wrote:

> I run a program which does some logging on files. I want to collect  
> all the filenames and handlers in the same structure. All the files  
> should be opened at startup, closed at exit, and easily accessed by  
> the rest of the script.

open them at the module level, and close them in an "atexit" handler (or 
if they're plain files, leave the closing to the garbage collector).

</F>




More information about the Python-list mailing list