closing file

Marcello Pietrobon teiffel at attglobal.net
Tue Apr 20 10:40:43 EDT 2004


Hello,

Once I open a file, for example as:
class MyClass:
    def logFileOpen( self ):
        self.fdFilenameLog = file( self.filenameLog, 'a' )
        return

I cannot find in hte documentation how to make sure the file are closed.

I guess that Python is closing all files at the end of the application 
or when an Exception is raised

Is this true ?
Is the file closed when the destructor is called ? ( Internally because 
I don't see a way to call a destructor in Python ).

Thank you very much,
Marcello





More information about the Python-list mailing list