byoc.arithmetic_eval

byoc.arithmetic_eval(expr: str) Union[int, float]

Evaluate the given arithmetic expression.

Parameters

expr – The expression to evaluate. The syntax is identical to python, but only int literals, float literals, binary operators (except left/right shift, bitwise and/or/xor, and matrix multiplication), and unary operators are allowed.

Returns

The value of the given expression.

Raises

It is safe to call this function on untrusted input, as there is no way to construct an expression that will execute arbitrary code.