All Projects → newville → Asteval

newville / Asteval

Licence: mit
minimalistic evaluator of python expression using ast module

Programming Languages

python
139335 projects - #7 most used programming language

Labels

Projects that are alternatives of or similar to Asteval

ctxexp-parser
In the dynamic execution of JS language environment (wechat applet) to execute JS class calling function.
Stars: ✭ 17 (-85.34%)
Mutual labels:  ast, eval
eval-estree-expression
Safely evaluate JavaScript (estree) expressions, sync and async.
Stars: ✭ 22 (-81.03%)
Mutual labels:  ast, eval
Csharp Eval Unity3d
C# Expression Parser for Unity3D
Stars: ✭ 102 (-12.07%)
Mutual labels:  ast, eval
Elm Markdown
Pure Elm markdown parsing and rendering
Stars: ✭ 96 (-17.24%)
Mutual labels:  ast
Esutils
utility box for ECMAScript language tools
Stars: ✭ 101 (-12.93%)
Mutual labels:  ast
Babel
🐠 Babel is a compiler for writing next generation JavaScript.
Stars: ✭ 40,109 (+34476.72%)
Mutual labels:  ast
Nlcst
Natural Language Concrete Syntax Tree format
Stars: ✭ 116 (+0%)
Mutual labels:  ast
Unimport
A linter, formatter for finding and removing unused import statements.
Stars: ✭ 96 (-17.24%)
Mutual labels:  ast
Yaep
Yet Another Earley Parser
Stars: ✭ 110 (-5.17%)
Mutual labels:  ast
Infection
PHP Mutation Testing library
Stars: ✭ 1,575 (+1257.76%)
Mutual labels:  ast
Pycode similar
A simple plagiarism detection tool for python code
Stars: ✭ 105 (-9.48%)
Mutual labels:  ast
Astviewer
Python Abstract Syntax Tree viewer in Qt
Stars: ✭ 101 (-12.93%)
Mutual labels:  ast
Prettier
Prettier is an opinionated code formatter.
Stars: ✭ 41,411 (+35599.14%)
Mutual labels:  ast
Birdseye
Graphical Python debugger which lets you easily view the values of all evaluated expressions
Stars: ✭ 1,373 (+1083.62%)
Mutual labels:  ast
Wasm Jseval
A safe eval library based on WebAssembly and Duktape/QuickJS.
Stars: ✭ 111 (-4.31%)
Mutual labels:  eval
Graphql Go Tools
Tools to write high performance GraphQL applications using Go/Golang.
Stars: ✭ 96 (-17.24%)
Mutual labels:  ast
Cgen
C/C++ source generation from an AST
Stars: ✭ 107 (-7.76%)
Mutual labels:  ast
Ts Transform Import Path Rewrite
TS AST transformer to rewrite import path
Stars: ✭ 104 (-10.34%)
Mutual labels:  ast
Yacep
yet another csharp expression parser
Stars: ✭ 107 (-7.76%)
Mutual labels:  ast
Eqcss
EQCSS is a CSS Reprocessor that introduces Element Queries, Scoped CSS, a Parent selector, and responsive JavaScript to all browsers IE8 and up
Stars: ✭ 1,513 (+1204.31%)
Mutual labels:  eval

ASTEVAL

.. image:: https://travis-ci.org/newville/asteval.png :target: https://travis-ci.org/newville/asteval

.. image:: https://codecov.io/gh/newville/asteval/branch/master/graph/badge.svg :target: https://codecov.io/gh/newville/asteval

.. image:: https://img.shields.io/pypi/v/asteval.svg :target: https://pypi.org/project/asteval

.. image:: https://img.shields.io/pypi/dm/asteval.svg :target: https://pypi.org/project/asteval

.. image:: https://zenodo.org/badge/4185/newville/asteval.svg :target: https://zenodo.org/badge/latestdoi/4185/newville/asteval

Links

What is it?

ASTEVAL is a safe(ish) evaluator of Python expressions and statements, using Python's ast module. The idea is to provide a simple, safe, and robust miniature mathematical language that can handle user-input. The emphasis here is on mathematical expressions, and so many functions from numpy are imported and used if available.

Many Python lanquage constructs are supported by default, These include slicing, subscripting, list comprehension, conditionals (if-elif-else blocks and if expressions), flow control (for loops, while loops, and try-except-finally blocks). All data are python objects, and built-in data structures (dictionaries, tuple, lists, numpy arrays, strings) are fully supported by default.

Many of the standard builtin python functions are available, as are all mathemetical functions from the math module. If the numpy module is installed, many of its functions will also be available. Users can define and run their own functions within the confines of the limitations of asteval.

There are several absences and differences with Python, and asteval is by no means an attempt to reproduce Python with its own ast module. Some of the most important differences and absences are:

  1. Variable and function symbol names are held in a simple symbol table (a single dictionary), giving a flat namespace.
  2. creating classes is not supported.
  3. importing modules is not supported.
  4. function decorators, yield, lambda, exec, and eval are not supported.
  5. files can only be opened in read-only mode.

In addition, accessing many internal methods and classes of objects is forbidden in order to strengthen asteval against malicious user code.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].