>>> variables = {'a': 6, 'b': 7}
>>> eval('a * b', globals=variables)
42
As a plus, with this the code cannot accidentally refer to the names defined outside:
>>> eval('variables')
{'a': 6, 'b': 7}
>>> eval('variables', globals=variables)
Traceback (most ...