def evaluate_formula(formula, variables):
    """Very simple formula evaluator. Beware the security.

    :param formula: A simple formula.
    :type formula: str

    :param variables: A collection of variable (key and value).
    :type variables: dict

    :returns: The result of the formula execution.
    :rtype: float, int
    """
    for key, value in list(variables.items()):
        if value is None or (hasattr(value, 'isNull') and value.isNull()):
            # If one value is null, we return null.
            return value
        formula = formula.replace(key, str(value))
    result = eval(formula)
    return result
def evaluate_formula ( formula , variables ) : for key , value in list ( variables . items ( ) ) : if value is None or ( hasattr ( value , 'isNull' ) and value . isNull ( ) ) : return value formula = formula . replace ( key , str ( value ) ) result = eval ( formula ) return result
Very simple formula evaluator. Beware the security.

    :param formula: A simple formula.
    :type formula: str

    :param variables: A collection of variable (key and value).
    :type variables: dict

    :returns: The result of the formula execution.
    :rtype: float, int