parsematic

parsematic source code (opens in a new tab)

Parsematic

A math expression parser written in Python that supports arithmetic, comparison, and mathematical functions.

Features

  • Basic arithmetic (+, -, *, /)
  • Exponents (**)
  • Parentheses
  • Comparison operators
  • Math functions (sin, cos, tan, sqrt, log)

Usage

from parsematic import parse

result = parse("2 + 3 * 4")
print(result)  # 14

result = parse("sqrt(16) + 2")
print(result)  # 6

↑↓ to move · Enter to open · Esc to close