Skip to content

Latest commit

 

History

History
27 lines (19 loc) · 446 Bytes

README.md

File metadata and controls

27 lines (19 loc) · 446 Bytes

A python expression evaluate library

Installation

pip install pyexpr

Usage

  • Simple evaluation
assert pyexpr.evaluate('1 + 2 * (3 - 4) **2') == 3
  • With functions
assert pyexpr.evaluate('1 + 2 * (3 - 4) ** sqrt(4)', builtins=dict(sqrt=math.sqrt)) == 3
  • With variables
assert pyexpr.evaluate('1 + 2 * (3 - 4) ** X', variables=dict(X=4)) == 3

You can find more examples in test.py