import re
SAFE_EVAL_RE = re.compile(r'^[-+/*()eE0-9.]+$')
def safeEval(string):
if not SAFE_EVAL_RE.match(string):
raise ValueError()
return eval(string)
def evaluate(value, variables, formulas, MAX_DEPTH=100):
tryAgain = True
depth = 0
while tryAgain and depth