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
|