__del__ not called?

Gregor Horvath g.horvath at gmx.at
Mon Mar 13 02:21:13 EST 2006


Hi,

I do not understand why __del__ does not get executed in the following 
example.

test.py:

#!/usr/bin/python
class A(object):
   def __init__(self):
     print "init"

   def __del__(self):
     print "del"

test1.py

#!/usr/bin/python
import test

class B(object):
   a = test.A()

Running test1.py outputs:

init

the "del" is missing.

I suppose the a object should be garbage collected!?


--
Gregor



More information about the Python-list mailing list