python-simpleeval
Port variant v14
Summary Single expression evaluator library (3.14)
Package version 1.0.8
Homepage https://pypi.org/project/simpleeval/
Keywords python
Maintainer Python Automaton
License Not yet specified
Other variants v15
Ravenports Buildsheet | History
Ravensource Port Directory | History
Last modified 13 NOV 2026, 13:25:52 UTC
Port created 22 OCT 2023, 16:37:00 UTC
Subpackage Descriptions
single simpleeval (Simple Eval) ======================== :alt: Build Status :alt: Code Coverage Status :alt: PyPI - Version .. |python-versions| image:: https://img.shields.io/badge/python-3.9_%7C_3.10_%7C_3.11_%7C_3.12_%7C_3.13_%7C_PyPy3.9_%7C_PyPy3.10-blue :alt: Static Badge .. |pypi-monthly-downloads| image:: https://img.shields.io/pypi/dm/SimpleEval :alt: PyPI - Downloads .. |formatting-with-ruff| image:: https://img.shields.io/badge/-ruff-black?logo=lightning&logoColor=%2300ff00&link=https%3A%2F%2Fdocs.astral.sh%2Fruff%2F :alt: Static Badge |build-status| |code-coverage| |pypi-version| |python-versions| |pypi-monthly-downloads| |formatting-with-ruff| A single file library for easily adding evaluatable expressions into python projects. Say you want to allow a user to set an alarm volume, which could depend on the time of day, alarm level, how many previous alarms had gone off, and if there is music playing at the time. Or if you want to allow simple formulae in a web application, but don't want to give full eval() access, or don't want to run in javascript on the client side. It's deliberately trying to stay simple to use and not have millions of features, pull it in from PyPI (pip or easy_install), or even just a single file you can dump into a project. Internally, it's using the amazing python ast module to parse the expression, which allows very fine control of what is and isn't allowed. It should be completely safe in terms of what operations can be performed by the expression. The only issue I know to be aware of is that you can create an expression which takes a long time to evaluate, or which evaluating requires an awful lot of memory, which leaves the potential for DOS attacks. There is basic protection against this, and you can lock it down further if you desire. (see the Operators_ section below) You should be aware of this when deploying in a public setting. The defaults are pretty locked down and basic, and it's easy to add whatever extra specific functionality you need (your own functions, variable/name lookup, etc). Basic Usage ----------- To get very simple evaluating: .. code-block:: python from simpleeval import simple_eval simple_eval("21 + 21") returns 42. Expressions can be as complex and convoluted as you want: .. code-block:: python simple_eval("21 + 19 / 7 + (8 % 3) ** 9") returns ``535.714285714``. You can add your own functions in as well. .. code-block:: python simple_eval("square(11)", functions={"square": lambda x: x*x}) returns 121. For more details of working with functions, read further down. Note: ~~~~~ all further examples use ``>>>`` to designate python code, as if you are using the python interactive prompt.
Configuration Switches (platform-specific settings discarded)
PY314 ON Build using Python 3.14 PY315 OFF Build using Python 3.15
Package Dependencies by Type
Build (only) python314:dev:std
python-pip:single:v14
autoselect-python:single:std
Build and Runtime python314:primary:std
Download groups
main mirror://PYPIWHL/12/33/d1ecd9f4f5f272b36ad7b268e307ba0a59c109d8ad134a231cda780baac9
Distribution File Information
c9c4ff42879ebf0c05f6562cb81031869948916be343bcc950b81fcc081fe9ce 18925 python-src/simpleeval-1.0.8-py3-none-any.whl
Ports that require python-simpleeval:v14
python-trytond-account:v14 Accounting for Tryton (3.14)
python-trytond-stock:v14 Stock and inventories for Tryton (3.14)
python-trytond:v14 Tryton server (3.14)