
April 5, 2000
5:19 a.m.
An even simpler example:
import sys d = {} print sys.getrefcount(d) 2 exec("def f(): pass\n") in d print sys.getrefcount(d) 3 d.clear() print sys.getrefcount(d) 2
exec adds the function to the dictionary. The function references the dictionary through globals. Neil -- "If elected mayor, my first act will be to kill the whole lot of you, and burn your town to cinders!" -- Groundskeeper Willie