Code: Alles auswählen
In [1]: testname = "foobar"
In [2]: from collections import defaultdict
In [3]: d = defaultdict(list)
In [4]: for k, v in globals().copy().iteritems():
...: d[id(v)].append(k)
...:
...:
In [6]: print repr(d[id(testname)])
['testname']
In [7]: print repr(d[id(d)])
['d']