Skip to main content

Evaluate Python arithemetic expressions safely.

Project description

astmath

Evaluate Python arithemetic expressions safely.

This package can help evaluate Python expressions, without any risk of code execution.

Installation

pip install astmath

Usage

Use it in the CLI:

$ astmath '40 + 2'
42
$ astmath '"foobar" * 2'
foobarfoobar

Or via the API:

>>> import astmath
>>> astmath.eval("2 + 3 * 4")
14
>>> astmath.eval("foo" * 3)
'foofoofoo'

Local Development / Testing

  • Create and activate a virtual environment
  • Run pip install -r requirements-dev.txt to do an editable install
  • Run pytest to run tests

Type Checking

Run mypy .

Create and upload a package to PyPI

Make sure to bump the version in setup.cfg.

Then run the following commands:

rm -rf build dist
python setup.py sdist bdist_wheel

Then upload it to PyPI using twine:

twine upload dist/*

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

astmath-0.1.0.tar.gz (3.5 kB view hashes)

Uploaded Source

Built Distribution

astmath-0.1.0-py3-none-any.whl (4.2 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page