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
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