Circular refs

Adrian Eyre a.eyre at optichrome.com
Mon Sep 27 11:06:59 EDT 1999


Is there a reasonable fix for this?

>>> class Noisy:
...     def __init__(self, name):
...         self._name = name
...         print "Created " + self._name
...     def __del__(self):
...         print "Destroyed " + self._name
...
>>> a = Noisy("a")
Created a
>>> b = Noisy("b")
Created b
>>> del a
Destroyed a
>>> del b
Destroyed b

Fair enough, but...

>>> a = Noisy("a")
Created a
>>> b = Noisy("b")
Created b
>>> a.b = b
>>> b.a = a
>>> del a
>>> del b
[Sound of memory dripping onto the floor]

--------------------------------------------
Adrian Eyre <mailto:a.eyre at optichrome.com>
Optichrome Computer Solutions Ltd
Maybury Road, Woking, Surrey, GU21 5HX, UK
Tel: +44 1483 740 233  Fax: +44 1483 760 644
http://www.optichrome.com 
--------------------------------------------





More information about the Python-list mailing list