RosettaCodeData/Task/Runtime-evaluation-In-an-environment/Python/runtime-evaluation-in-an-environment-1.py
Ingy döt Net b83f433714 tasks a-s
2013-04-10 23:57:08 -07:00

5 lines
119 B
Python

>>> def eval_with_x(code, a, b):
return eval(code, {'x':b}) - eval(code, {'x':a})
>>> eval_with_x('2 ** x', 3, 5)
24