A mathematical expression parser and evaluator.
Project description
meth: A mathematical expression parser.
A python package to parse and evaluate mathematical expressions.
Installation
pip install meth
or install it from source:
git clone https://github.com/sertdfyguhi/meth/
cd meth
python3 -m build
pip install dist/*.whl
Examples
More examples in the examples/ directory.
import meth
# tokenizing equations
tokens = meth.tokenize("5 + 2") # Token(NUMBER, 5), Token(+), Token(NUMBER, 2)
# parsing equations
ast = meth.parse(tokens) # BinaryOp(Number(5), +, Number(2))
# evaluating equations
meth.evaluate("2 + 2") # 4
meth.evaluate("sqrt(9)") # 3
# evaluation with variables
evaluator = meth.Evaluator()
evaluator.evaluate("x = 5")
evaluator.evaluate("x") # 5
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
meth-2.0.0.tar.gz
(19.2 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
meth-2.0.0-py3-none-any.whl
(21.0 kB
view details)
File details
Details for the file meth-2.0.0.tar.gz.
File metadata
- Download URL: meth-2.0.0.tar.gz
- Upload date:
- Size: 19.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
81dd35062c5c330cdc777c6da7560519b6ea3613ded9fbedc91b944333d25d46
|
|
| MD5 |
95d790b66611a0cf09ad7f468f4a90e7
|
|
| BLAKE2b-256 |
22bb3c3e9f2e281bdb1a419e4dd22fb6aa0617b7cbad08f9e646288412d1b84c
|
File details
Details for the file meth-2.0.0-py3-none-any.whl.
File metadata
- Download URL: meth-2.0.0-py3-none-any.whl
- Upload date:
- Size: 21.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5931c3fb246bedf40063447bbb18d7f9c79b8274968e0513aa682a9666090299
|
|
| MD5 |
59c3e962a4ed631b8edd91a1f3f69154
|
|
| BLAKE2b-256 |
0c3fa87d39906aea60c421b1148936b1cfabb1c96255d45db5a373cad8e0279f
|