(statement, variable_context)
return evaluator.eval(statement)
Evaluates math statements and returns the value

    args
        statement: a simple python-like math statement
        variable_context: a dict with variable names as key and assigned values as dict values
Evaluates math statements and returns the value
Evaluates math statements and returns the value
def eval_statements(statement, variable_context):
    """Evaluates math statements and returns the value

    args
        statement: a simple python-like math statement
        variable_context: a dict with variable names as key and assigned values as dict values
    """
    # variable values should be numbers
    var_types = set(type(value) for value in variable_context.values())
    if not var_types.issubset({float, Decimal, date, datetime, type(None), bool}.union(set(six.integer_types))):
        raise InvalidExpression('Context contains disallowed types')

    evaluator = EvalNoMethods(operators=SAFE_OPERATORS, names=variable_context, functions=FUNCTIONS)
    return evaluator.eval(statement)
def eval_statements ( statement , variable_context ) : # variable values should be numbers var_types = set ( type ( value ) for value in variable_context . values ( ) ) if not var_types . issubset ( { float , Decimal , date , datetime , type ( None ) , bool } . union ( set ( six . integer_types ) ) ) : raise InvalidExpression ( 'Context contains disallowed types' ) evaluator = EvalNoMethods ( operators = SAFE_OPERATORS , names = variable_context , functions = FUNCTIONS ) return evaluator . eval ( statement )