I have a list of variable names, like this:
[\'foo\', \'bar\', \'baz\']
(I originally asked how I convert a list of variables. See Greg He
Not efficient, but without invoking eval:
eval
dict((k,v) for (k,v) in globals().iteritems() if k in list_of_variable_names)
or
dict((k,v) for (k,v) in vars().iteritems() if k in list_of_variable_names)
depending on what you want.