On Sat, 19 Jan 2013 16:24:37 +0000, Steven D'Aprano wrote: > On Sat, 19 Jan 2013 14:47:16 +0000, Jens Thoms Toerring wrote: > >> Ok, the destrucor for the first instance of the X class is called only >> after printing out "After", so the GC didn't delete the object before. >> But then there are obviously no calls of the destructors of neither the >> second instance of the X class nor of the Y class instance. Shouldn't >> they be invoked before the program ends? > > You should avoid __del__ destructors whenever not absolutely necessary.
And here is another opinion: you should avoid cycles, rather the __del__. http://eli.thegreenplace.net/2009/06/12/safely-using-destructors-in-python/ -- Steven -- http://mail.python.org/mailman/listinfo/python-list