Problems when destroy object which is referenced member objects

Minkyu Kim levites at lycos.co.kr
Thu Feb 19 08:57:40 EST 2004


Hi.
Please check this simple test code.

---------------------
class TestA: 
   def __init__(self): 
      print "init TestA" 
   def __del__(self): 
      print "del TestA" 
   def SetEvent(self, event): 
      self.event = event 

class TestB: 
   def __init__(self): 
      print "init TestB" 
      self.testA = TestA() 
      self.testA.SetEvent(self.Test) 
   def __del__(self): 
      print "del TestB" 
   def Test(self): 
      pass 

testB = TestB() 
del testB
---------------------

I want to run this code that destroy testB and testB's member object
testA. But no object destroy. I know testA increase testB's reference
count, but why wouldn't python decrease testB's reference count? Had I
do wrong something?



More information about the Python-list mailing list