By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,548 Members | 1,496 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,548 IT Pros & Developers. It's quick & easy.

closing file

P: n/a
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
Jul 18 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
In article <ma**************************************@python.o rg>,
Marcello Pietrobon <te*****@attglobal.net> wrote:
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.


File objects have a close() method that you can call. See
<http://docs.python.org/lib/bltin-file-objects.html>

-Mark
Jul 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.