skillfed

py-expression-eval

Python Mathematical Expression Evaluator

py-expression-eval v0.3.14 150.9K downloads/30d#10,951 on PyPI150
Permissive license MIT Abandoned released

What it is and what it does

py-expression-eval is a mathematical expression parser and evaluator ported from a JavaScript library. It takes mathematical expressions as strings and converts them into evaluable objects that can be computed with variable substitution. The library supports standard arithmetic operators, trigonometric and logarithmic functions, boolean logic, and constants like PI and E.

You create a Parser instance, call parse() on an expression string to get an Expression object, then evaluate() it with a dictionary of variable values. The library also offers simplification (reducing expressions algebraically), substitution (replacing variables with other expressions), and variable extraction. It's useful for applications that need to accept user-supplied or configuration-based mathematical formulas without executing arbitrary code.

Use it for:

  • Accept mathematical formulas from users in web forms or configuration files and compute results safely
  • Build spreadsheet-like applications where cells contain formulas referencing other cells
  • Implement rule engines or business logic systems that rely on user-defined mathematical conditions
  • Validate and simplify mathematical expressions in educational or scientific tools
  • Generate dynamic calculations in data processing pipelines where formulas are stored as strings

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Parses and evaluates mathematical expressions from strings, supporting arithmetic, trigonometric, logarithmic functions, and variables with substitution and simplification.

Yes, if you need a lightweight, dependency-free expression evaluator for a stable use case. The package is mature and has no known vulnerabilities. However, do not use it for new projects requiring active maintenance or support—the repository is archived and the last commit was 2022-06-11. For actively maintained alternatives or complex symbolic math, consider other options.

Install

py-expression-eval on PyPI

pip

pip install py-expression-eval

uv

uv add py-expression-eval

poetry

poetry add py-expression-eval

Installing py-expression-eval

Before you install

Installation is straightforward with no runtime dependencies. However, the repository is archived and the last commit was 2022-06-11, indicating the project is no longer actively maintained.

License in practice

Licensed under MIT (permissive), allowing free use, modification, and distribution with minimal restrictions.

Quickstart

pip install py-expression-eval

from py_expression_eval import Parser

parser = Parser()
result = parser.parse('2 * x + 1').evaluate({'x': 3})
print(result)  # 7

Verify before relying

  • Whether the package handles edge cases in expression parsing (division by zero, invalid syntax) gracefully
  • Performance characteristics when evaluating complex nested expressions or with many variables
  • Compatibility with Python versions beyond 3.9, given the latest release predates newer Python versions

Package facts

License MIT (permissive)
Python support not specified
Install friction low — pure-Python wheel
Runtime dependencies none
Maintenance abandoned — 1,814 days since the last release
Last repo commit (repository archived)
First released
Downloads 150,894/month — #10,951 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: py_expression_eval-0.3.14-py3-none-any.whl

Development Status :: 5 - Production/StableIntended Audience :: DevelopersProgramming Language :: PythonProgramming Language :: Python :: 2Programming Language :: Python :: 2.7Programming Language :: Python :: 3Programming Language :: Python :: 3.5Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9

Tags

parse mathematical expressionsevaluate math formulas from stringsexpression parser evaluatormath expression simplificationvariable substitution mathtrigonometric function evaluatorsymbolic math expression
math-parserexpression-evaluatorformula-engine

More Mathematics packages