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.txtto do an editable install - Run
pytestto 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/*
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 details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file astmath-0.1.0.tar.gz.
File metadata
- Download URL: astmath-0.1.0.tar.gz
- Upload date:
- Size: 3.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
42349944806e06cbfdc5a2e0c83eb301a061216ab61b494878ff43ba49cefc1f
|
|
| MD5 |
8e71b92ff23d641f8c5516ea085f5c87
|
|
| BLAKE2b-256 |
e2c33b730aaac52b513396f9180381675a74bdc4f8d7e5868f876027dc8baf6c
|
File details
Details for the file astmath-0.1.0-py3-none-any.whl.
File metadata
- Download URL: astmath-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9f7e7d6c091eff8a469d31f0bf6db252f49171d80cf916a2059b991e948b9c6b
|
|
| MD5 |
670156eed83fc97f4885517b0f237447
|
|
| BLAKE2b-256 |
bd1e464987272df3309144bea7f512f3889db30784f30dfc09797f69c5c18b8e
|