SyntaxFix
Write A Post
Hire A Developer
Questions
You could do:
import inspect mydict = {'one': 1, 'two': 2} source = inspect.getsourcelines(inspect.getmodule(inspect.stack()[0][0]))[0] print [x for x in source if x.startswith("mydict = ")]
Also: make sure not to shadow the dict builtin!