# 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:
```console
$ astmath '40 + 2'
42
$ astmath '"foobar" * 2'
foobarfoobar
```
Or via the API:
```pycon
>>> 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:
```bash
rm -rf build dist
python setup.py sdist bdist_wheel
```
Then upload it to PyPI using [twine](https://twine.readthedocs.io/en/latest/#installation):
```bash
twine upload dist/*
```
Raw data
{
"_id": null,
"home_page": "https://github.com/tusharsadhwani/astmath",
"name": "astmath",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": "",
"keywords": "",
"author": "Tushar Sadhwani",
"author_email": "tushar.sadhwani000@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/e2/c3/3b730aaac52b513396f9180381675a74bdc4f8d7e5868f876027dc8baf6c/astmath-0.1.0.tar.gz",
"platform": null,
"description": "# astmath\n\nEvaluate Python arithemetic expressions safely.\n\nThis package can help evaluate Python expressions, without any risk of\ncode execution.\n\n## Installation\n\n```\npip install astmath\n```\n\n## Usage\n\nUse it in the CLI:\n\n```console\n$ astmath '40 + 2'\n42\n$ astmath '\"foobar\" * 2'\nfoobarfoobar\n```\n\nOr via the API:\n\n```pycon\n>>> import astmath\n>>> astmath.eval(\"2 + 3 * 4\")\n14\n>>> astmath.eval(\"foo\" * 3)\n'foofoofoo'\n```\n\n## Local Development / Testing\n\n- Create and activate a virtual environment\n- Run `pip install -r requirements-dev.txt` to do an editable install\n- Run `pytest` to run tests\n\n## Type Checking\n\nRun `mypy .`\n\n## Create and upload a package to PyPI\n\nMake sure to bump the version in `setup.cfg`.\n\nThen run the following commands:\n\n```bash\nrm -rf build dist\npython setup.py sdist bdist_wheel\n```\n\nThen upload it to PyPI using [twine](https://twine.readthedocs.io/en/latest/#installation):\n\n```bash\ntwine upload dist/*\n```\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Evaluate Python arithemetic expressions safely.",
"version": "0.1.0",
"project_urls": {
"Homepage": "https://github.com/tusharsadhwani/astmath"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "bd1e464987272df3309144bea7f512f3889db30784f30dfc09797f69c5c18b8e",
"md5": "670156eed83fc97f4885517b0f237447",
"sha256": "9f7e7d6c091eff8a469d31f0bf6db252f49171d80cf916a2059b991e948b9c6b"
},
"downloads": -1,
"filename": "astmath-0.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "670156eed83fc97f4885517b0f237447",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 4227,
"upload_time": "2023-05-22T07:24:54",
"upload_time_iso_8601": "2023-05-22T07:24:54.082549Z",
"url": "https://files.pythonhosted.org/packages/bd/1e/464987272df3309144bea7f512f3889db30784f30dfc09797f69c5c18b8e/astmath-0.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "e2c33b730aaac52b513396f9180381675a74bdc4f8d7e5868f876027dc8baf6c",
"md5": "8e71b92ff23d641f8c5516ea085f5c87",
"sha256": "42349944806e06cbfdc5a2e0c83eb301a061216ab61b494878ff43ba49cefc1f"
},
"downloads": -1,
"filename": "astmath-0.1.0.tar.gz",
"has_sig": false,
"md5_digest": "8e71b92ff23d641f8c5516ea085f5c87",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 3474,
"upload_time": "2023-05-22T07:24:56",
"upload_time_iso_8601": "2023-05-22T07:24:56.521743Z",
"url": "https://files.pythonhosted.org/packages/e2/c3/3b730aaac52b513396f9180381675a74bdc4f8d7e5868f876027dc8baf6c/astmath-0.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-05-22 07:24:56",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "tusharsadhwani",
"github_project": "astmath",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [],
"tox": true,
"lcname": "astmath"
}