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.tar.gz (15.0 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

Details for the file sheval-1.1.0.tar.gz.

File metadata

  • Download URL: sheval-1.1.0.tar.gz
  • Upload date:
  • Size: 15.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.8

File hashes

Hashes for sheval-1.1.0.tar.gz
Algorithm Hash digest
SHA256 753ccff41c293b0987fc0e3c82dce9a5ecb828f3e527b3b65ad3d90a2e11b188
MD5 654ba52ac08c13c4858ede929740ef70
BLAKE2b-256 7899c7e996a7e212a9786b0109302af5d0969cc5b7afd9e70663ab1dace7a65f

See more details on using hashes here.

File details

Details for the file sheval-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: sheval-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 15.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.8

File hashes

Hashes for sheval-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 05f203c18f80126f58b5422ad88b50413e01fd3b8f94bfbd45beaebffbd903c5
MD5 f971e62523e5a352e35657520fca7156
BLAKE2b-256 0009786314172e3ac20d96988ab31b7b4b19e3bfb7827849c073a3c646923830

See more details on using hashes here.

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