Evaluate infix math expresion in python with ease.
Project description
InfixParser
InfixParser is a Python binding for MathParser (https://github.com/KJ002/MathParser/). This module allows for a simple and quick evaluation of strings. It allows you to evaluate a string with security, you define the external variables!
Examples
Basic Eval
result: float = InfixParser.evaluate("1+1") # returns 2.0
Basic Eval (With Evaluator Class)
parser = InfixParser.Evaluator()
result: float = parser.eval("1+1") # returns 2.0
External Variable Eval
parser = InfixParser.Evaluator()
x: int = 20
parser.append_variable("x", x)
result: float = parser.eval("1+x") # returns 21.0
Updating External Variable Eval
parser = InfixParser.Evaluator()
x: int = 20
parser.append_variable("x", x)
result1: float = parser.eval("1+x") # returns 21.0
x: int = 10
parser.append_variable("x", x)
result2: float = parser.eval("1+x") # returns 11.0
Functions Eval
parser = InfixParser.Evaluator()
result: float = parser.eval("sin(1.5707963267948966)") # returns 1.0
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
InfixParser-3.1.2.tar.gz
(7.3 kB
view hashes)
Built Distributions
Close
Hashes for InfixParser-3.1.2-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eb2fb82365ed121f263deba62c6f735a43e5d4e2dbd442afb6e87d006a2b6512 |
|
MD5 | d41800c2c1177a0c8b110a4fd5918f3e |
|
BLAKE2b-256 | d5b0e6c1d063001169c96bded1abe0da2d021ecd4751b0745bba6fe6db326b87 |
Close
Hashes for InfixParser-3.1.2-cp35-cp35m-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dedebf6721f9483e64f5e671c3cc46404dfbb39a92e36e47818d3701ffa18a5c |
|
MD5 | d324fdf4d771dc6501838b65022d7f48 |
|
BLAKE2b-256 | a457c9426b01300a6c7c91bbc9ec14c82020708c42847df948594a9d9341fc01 |