Skip to main content

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/*

Release files for astmath 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for astmath 0.1.0
File Size Uploaded
astmath-0.1.0.tar.gz 3.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for astmath 0.1.0
File Interpreter ABI Platform
astmath-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 7.7 kB

Release files / astmath-0.1.0.tar.gz

Download URL astmath-0.1.0.tar.gz
Size 3.5 kB
Tags Source
SHA-256 checksum
How to use checksums
42349944806e06cbfdc5a2e0c83eb301a061216ab61b494878ff43ba49cefc1f
BLAKE2b-256 checksum
How to use checksums
e2c33b730aaac52b513396f9180381675a74bdc4f8d7e5868f876027dc8baf6c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.2

Release files / astmath-0.1.0-py3-none-any.whl

Download URL astmath-0.1.0-py3-none-any.whl
Size 4.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9f7e7d6c091eff8a469d31f0bf6db252f49171d80cf916a2059b991e948b9c6b
BLAKE2b-256 checksum
How to use checksums
bd1e464987272df3309144bea7f512f3889db30784f30dfc09797f69c5c18b8e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.2

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page