scope = {} scope['x'] = 2 scope['y'] = 3 eval('x * y', scope) scope = {} exec 'x = 2' in scope eval('x*x', scope)