Skip to main content

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)

evaluator = InfixParser.Evaluator()

result: float = evaluator.eval("1+1") # returns 2.0

External Variable Eval

evaluator = InfixParser.Evaluator()

x: int = 20

evaluator.append_variable("x", x)

result: float = evaluator.eval("1+x") # returns 21.0

Updating External Variable Eval

evaluator = InfixParser.Evaluator()

x: int = 20

evaluator.append_variable("x", x)

result1: float = evaluator.eval("1+x") # returns 21.0

x: int = 10

evaluator.append_variable("x", x)

result2: float = evaluator.eval("1+x") # returns 11.0

Functions Eval

"""
It is important to note that function do not have to
have to be called with in an instantiated class
and can just be called with InfixParser.evaluate()
"""

evaluator = InfixParser.Evaluator()

result: float = evaluator.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.4.tar.gz (7.4 kB view hashes)

Uploaded Source

Built Distributions

InfixParser-3.1.4-pp37-pypy37_pp73-win_amd64.whl (83.3 kB view hashes)

Uploaded PyPy Windows x86-64

InfixParser-3.1.4-pp37-pypy37_pp73-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (119.9 kB view hashes)

Uploaded PyPy manylinux: glibc 2.12+ x86-64

InfixParser-3.1.4-pp37-pypy37_pp73-manylinux_2_12_i686.manylinux2010_i686.whl (127.0 kB view hashes)

Uploaded PyPy manylinux: glibc 2.12+ i686

InfixParser-3.1.4-cp39-cp39-win_amd64.whl (83.4 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

InfixParser-3.1.4-cp39-cp39-win32.whl (73.4 kB view hashes)

Uploaded CPython 3.9 Windows x86

InfixParser-3.1.4-cp39-cp39-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (127.3 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.12+ x86-64

InfixParser-3.1.4-cp39-cp39-manylinux_2_12_i686.manylinux2010_i686.whl (135.1 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.12+ i686

InfixParser-3.1.4-cp38-cp38-win_amd64.whl (84.3 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

InfixParser-3.1.4-cp38-cp38-win32.whl (73.3 kB view hashes)

Uploaded CPython 3.8 Windows x86

InfixParser-3.1.4-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (127.3 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.12+ x86-64

InfixParser-3.1.4-cp38-cp38-manylinux_2_12_i686.manylinux2010_i686.whl (134.9 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.12+ i686

InfixParser-3.1.4-cp37-cp37m-win_amd64.whl (84.6 kB view hashes)

Uploaded CPython 3.7m Windows x86-64

InfixParser-3.1.4-cp37-cp37m-win32.whl (74.0 kB view hashes)

Uploaded CPython 3.7m Windows x86

InfixParser-3.1.4-cp37-cp37m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (127.7 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.12+ x86-64

InfixParser-3.1.4-cp37-cp37m-manylinux_2_12_i686.manylinux2010_i686.whl (135.8 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.12+ i686

InfixParser-3.1.4-cp36-cp36m-win_amd64.whl (84.6 kB view hashes)

Uploaded CPython 3.6m Windows x86-64

InfixParser-3.1.4-cp36-cp36m-win32.whl (73.9 kB view hashes)

Uploaded CPython 3.6m Windows x86

InfixParser-3.1.4-cp36-cp36m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (127.7 kB view hashes)

Uploaded CPython 3.6m manylinux: glibc 2.12+ x86-64

InfixParser-3.1.4-cp36-cp36m-manylinux_2_12_i686.manylinux2010_i686.whl (135.7 kB view hashes)

Uploaded CPython 3.6m manylinux: glibc 2.12+ i686

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page