If you have a string that contains Python literals, such as strings, floats etc, you can use ast.literal_eval to evaluate its value instead of eval. This has the added feature of allowing only certain syntax.
>>> import ast
>>> code = """(1, 2, {'foo': 'bar'})"...