A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/attachments/20080825/bc93b24a/attachment.py below:

import gc, weakref def test_container_iterator(i): class C(object): pass obj = C() ref = weakref.ref(obj) if i == 1: container = (obj,) elif i==2: container = [obj,] elif i==3: container = {obj: 1} elif i==4: container = {1: obj} print "Container:", container, obj.x = iter(container) del obj, container gc.collect() if ref() is None: print "OK" else: print "Cycle was not collected!!" # Break the cycle del ref().x # Now it is. assert ref() is None test_container_iterator(1) test_container_iterator(2) test_container_iterator(3) test_container_iterator(4)

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4