Python Math Expression Parser
Project description
python math expression parser is a python project where you can parse or evaluate math expressions.
This algorithm does not use a decision tree. It is a recursive algorithm.
Installation
pip install pymep
Here you can see some examples:
Real Numbers:
from pymep.realParser import parse
from pymep.realParser import eval
#Real Expresion parser
fx="cos(10)"
print(parse(fx))
xi=5
fx = "1 + x"
print(eval(fx, xi))
For complex Numbers:
from pymep.complexParser import parse
from pymep.complexParser import eval
from pymep.complex import Complex
#Operation with complex numbers
a = Complex(1,2)
print(a.__radd__(10).__complex__())
print(Complex.radd(10, a).__complex__())
#Complex Expresion parser
fx="cos(10+2j)"
print(parse(fx).__complex__())
xi=5
fx = "1 +j+x"
print(eval(fx, xi).__complex__())
There is a full list of examples inside!!
Enjoy it!!
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
pymep-1.0.1.tar.gz
(6.2 kB
view hashes)
Built Distribution
pymep-1.0.1-py3-none-any.whl
(11.7 kB
view hashes)