Skip to main content

Safe, minimalistic evaluator of python expression using ast module

Project description

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 numpy functions are imported and used if available.

While much of Python’s constructs are supported, there are important absences and differences, and this is by no means an attempt to reproduce Python with its own ast module. 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, and exec are not supported.

Many built-in python syntactical components (if-then-else, while loops, for loops, try-except blocks, list comprehension, slicing, subscripting), and built-in data structures (dictionaries, tuple, lists, numpy arrays, strings) are fully supported. In addition, many built-in functions are supported, including the standard builtin python functions, and all mathemetical functions from the math module. As mentioned above, if numpy is available, many of its functions will also be available. Users can define their own functions, but given the restrictions of not being able to define classes or import modules, the language is decidedly limited.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

asteval-0.9.tar.gz (25.7 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

asteval-0.9.win32-py3.2.exe (208.5 kB view details)

Uploaded Source

asteval-0.9.win32-py2.7.exe (208.5 kB view details)

Uploaded Source

asteval-0.9.win32-py2.6.exe (208.5 kB view details)

Uploaded Source

File details

Details for the file asteval-0.9.tar.gz.

File metadata

  • Download URL: asteval-0.9.tar.gz
  • Upload date:
  • Size: 25.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for asteval-0.9.tar.gz
Algorithm Hash digest
SHA256 4b5b37d1e7c09bb72e7b435c7729f63d5d0c21ca6fedd30a423cecab6101cd74
MD5 6c9a0e647ebdd518897ee0136b456fcf
BLAKE2b-256 0b39a026f18086270cc3081375137dfaa73bad9f1feec7999c6d0a642a60755b

See more details on using hashes here.

File details

Details for the file asteval-0.9.win32-py3.2.exe.

File metadata

File hashes

Hashes for asteval-0.9.win32-py3.2.exe
Algorithm Hash digest
SHA256 19c909cc665c9a95a173ad3d3d2dc7b0122d3d96b1ca18a8b73a41257109a8b4
MD5 064e79aaa5ac9d8ba3ad5deda70dbef4
BLAKE2b-256 9e353bbf629c12ebae0c233d75a5f25a842dc87926785f76ac57c490c6da858c

See more details on using hashes here.

File details

Details for the file asteval-0.9.win32-py2.7.exe.

File metadata

File hashes

Hashes for asteval-0.9.win32-py2.7.exe
Algorithm Hash digest
SHA256 ba743dedc4c86bae34cf78d7c9930f024cbcc18d20df66ca9b1861db79182b17
MD5 388bd02a317d9aafe6c1276f99642d82
BLAKE2b-256 139c7ae58cf7450241860f553632847dfa9ed147c26b277c40220d8837b21579

See more details on using hashes here.

File details

Details for the file asteval-0.9.win32-py2.6.exe.

File metadata

File hashes

Hashes for asteval-0.9.win32-py2.6.exe
Algorithm Hash digest
SHA256 66f0aecfcc297fb539b3e89a60a078f3e3f1a118f985f29661eab00a4dfc6354
MD5 fd47369c8fee0aa85fe69faf553951cd
BLAKE2b-256 c2b1f8061d3b3dbe37519c3f705cba22b4a6bc28c531b57f13b6dd887bf77b31

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page