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 details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: sheval-1.1.0.post1.tar.gz
  • Upload date:
  • Size: 14.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.8

File hashes

Hashes for sheval-1.1.0.post1.tar.gz
Algorithm Hash digest
SHA256 cc991b34e63cf50014c21fe8af1d1985cc3ef91f47713a059f3344d97c48131b
MD5 1215b61c7e73aeb8aad3a410f02054c6
BLAKE2b-256 ba87de1fc542ad43219248ef425cbcdb9cf4caed92c9dbfa3dbde251aaa88524

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for sheval-1.1.0.post1-py3-none-any.whl
Algorithm Hash digest
SHA256 af3fdf52e0c52c5e7b8548e6e364b496c581c45434ba385e89876c664c975a75
MD5 f9858fccb6b36db4260858db60aa664b
BLAKE2b-256 a94043d6c16c71a4581e4a7e0be8bbafcc97ec28c3f23f11b83de90034a1c7a8

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