How do I access Python's dictionary of all global variables?
Michael Hudson
mwh at python.net
Tue Feb 24 07:30:25 EST 2004
Josiah Carlson <jcarlson at nospam.uci.edu> writes:
> > For reference, this can be done using a debug build of the interpreter.
> > I don't recall the name of the function or even which module it was
> > in (sys or gc, presumably) but it was there. (I think. :-)
There's gc.get_objects(), present in all builds, which gives a list of
all objects tracked by the cycle collector (i.e. all containers).
In a debug build there's sys.getobjects(), which gives a list of
(potentially, depending on arguments passed) all objects known to the
interpreter.
> That scares me, it is very dangerous.
Why? It can be useful for tracking refleak problems, if nothing else.
Cheers,
mwh
--
I have a cat, so I know that when she digs her very sharp claws into
my chest or stomach it's really a sign of affection, but I don't see
any reason for programming languages to show affection with pain.
-- Erik Naggum, comp.lang.lisp
More information about the Python-list
mailing list