Skip to main content

Safely evaluate mathematical and logical expressions.

Project description

🐴 sheval

Safely evaluate mathematical and logical expressions. Most operations are supported.

Whitelisted data types

For security, only certain data types are allowed for constants and variables.

  • str
  • int
  • float
  • complex
  • list
  • tuple
  • set
  • dict
  • bool
  • bytes
  • NoneType

Example

from sheval import sheval

# Variables can be passed on.
variables = dict(
    x =  2,
    y =  3,
)
# And functions too!
functions = dict(
    double = lambda x: x * 2,
)

sheval('double(x) > y', variables, functions)

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

sheval-1.1.0.post1.tar.gz (14.7 kB view hashes)

Uploaded Source

Built Distribution

sheval-1.1.0.post1-py3-none-any.whl (15.1 kB view hashes)

Uploaded Python 3

Supported by

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