Skip to main content

meth: A mathematical expression evaluator.

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 expression
meth.tokenize("5 + 2") # [Token(TokenType.NUMBER, 5), Token(TokenType.ADD), Token(TokenType.NUMBER, 2)]

# parsing expression
meth.parse("7 * 2") # BinaryOp(Number(7), TokenType.MUL, Number(2))

# evaluating expression
meth.evaluate("4 ^ 2") # 16
meth.evaluate("3(1 + 2)") # 9
meth.evaluate("sqrt(9)") # 3

# evaluation with variables
evaluator = meth.Evaluator()
evaluator.evaluate("x = 5")
evaluator.evaluate("x") # 5

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.1.2.tar.gz (21.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

meth-2.1.2-py3-none-any.whl (23.3 kB view details)

Uploaded Python 3

File details

Details for the file meth-2.1.2.tar.gz.

File metadata

  • Download URL: meth-2.1.2.tar.gz
  • Upload date:
  • Size: 21.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.13

File hashes

Hashes for meth-2.1.2.tar.gz
Algorithm Hash digest
SHA256 59f2502898a8cc215db033a1444aeed4e8e4ceed222faa3662072d18c652a46e
MD5 551c8605747b2b19f24212976b3d7f45
BLAKE2b-256 3f78ccb5789b12e8ce2bad8d100be77208c79e43b58a33c1bb2785c5d9a3669b

See more details on using hashes here.

File details

Details for the file meth-2.1.2-py3-none-any.whl.

File metadata

  • Download URL: meth-2.1.2-py3-none-any.whl
  • Upload date:
  • Size: 23.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.13

File hashes

Hashes for meth-2.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e95bce80b1dd37ed510c032823e5cb55c0350320f6f2f748a98da80a1149f3ac
MD5 b2799ee249ab1eb162355e4de3853e9b
BLAKE2b-256 44b7c26df015b3cb9dace1c36d5cdf71391c999f7048cea7c24cc85a2ccdff84

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

2.1.2 This release

2 files

2.1.1

2 files

2.1.0

2 files

2.0.0

2 files

1.2.1

2 files

1.2.0

2 files

1.1.0

2 files

1.0.1

2 files

1.0.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page