# Buildsheet autogenerated by ravenadm tool -- Do not edit. NAMEBASE= python-simpleeval VERSION= 0.9.13 KEYWORDS= python VARIANTS= v11 v12 SDESC[v11]= Single expression evaluator library (3.11) SDESC[v12]= Single expression evaluator library (3.12) HOMEPAGE= https://github.com/danthedeckie/simpleeval CONTACT= Python_Automaton[python@ironwolf.systems] DOWNLOAD_GROUPS= main SITES[main]= PYPIWHL/0a/51/bedb4af4f3fe4bb32a3cabfd285be388958c6d676f6b0fa65997812a381b DISTFILE[1]= simpleeval-0.9.13-py2.py3-none-any.whl:main DF_INDEX= 1 SPKGS[v11]= single SPKGS[v12]= single OPTIONS_AVAILABLE= PY311 PY312 OPTIONS_STANDARD= none VOPTS[v11]= PY311=ON PY312=OFF VOPTS[v12]= PY311=OFF PY312=ON DISTNAME= simpleeval-0.9.13.dist-info GENERATED= yes [PY311].USES_ON= python:v11,wheel [PY312].USES_ON= python:v12,wheel [FILE:2697:descriptions/desc.single] simpleeval (Simple Eval) ======================== :alt: Build Status :alt: Code Coverage :alt: PyPI Version 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. .. _Operators: Operators --------- You can add operators yourself, using the operators argument, but these are the defaults: +--------+------------------------------------+ | ``+`` | add two things. ``x + y`` | | | ``1 + 1`` -> 2 | +--------+------------------------------------+ | ``-`` | subtract two things ``x - y`` | | | ``100 - 1`` -> 99 | +--------+------------------------------------+ | ``/`` | divide one thing by another | [FILE:117:distinfo] 22a2701a5006e4188d125d34accf2405c2c37c93f6b346f2484b6422415ae54a 15277 simpleeval-0.9.13-py2.py3-none-any.whl