ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> python-list
python-list
question on garbage collection for python
by della other posts by this author
Jun 1 2004 3:35AM messages near this date
question on garbage collection for python | PyAC 0.0.2
David Stockwell wrote:
>  The questions here are:
>  If in my code if I forget to close a file, when will the file be 
>  closed?  Is it when something goes out of scope?  Or will it close when 
>  the python session ends?

It isn't specified: it will be collected before the end of the program. 
I think that CPython would do it when the refcount goes to 0, whereas in 
Jython it will happen "sometimes in the future". Don't count on it, though!

>  If I define a class of somesort, is there a way I can have a destructor 
>  method (like I would under C++ ?)

The __del__ method.

-- 
Ciao,
Matteo
Thread:
winexpert
tjreedy
della

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved