Skip to main content

embexpr

https://travis-ci.org/orisano/embexpr.svg?branch=master https://badge.fury.io/py/embexpr.svg https://img.shields.io/pypi/pyversions/embexpr.svg
safe embedded python expression parser (for mainly easy DSL or config file).

Getting Started

pip install embexpr

How to Use

from embexpr import Expr, ParseError

assert Expr('3 * 5')() == 15
assert Expr('"foo" + "bar"')() == "foobar"
assert Expr('len("example")')() == 7
assert Expr('s.startswith("prefix_")')(s="prefix_suffix") == True

try:
    Expr('eval("1")')()
except ParseError as e:
    print(e)

Reference

https://github.com/ansible/ansible/blob/devel/lib/ansible/template/safe_eval.py http://stackoverflow.com/questions/12523516/using-ast-and-whitelists-to-make-pythons-eval-safe

Author

Nao Yonashiro(@orisano)

License

MIT

Metadata

Release files for embexpr 1.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for embexpr 1.1.1
File Size Uploaded
embexpr-1.1.1.tar.gz 4.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for embexpr 1.1.1
File Interpreter ABI Platform
embexpr-1.1.1-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 9.0 kB

Release files / embexpr-1.1.1.tar.gz

Download URL embexpr-1.1.1.tar.gz
Size 4.5 kB
Tags Source
SHA-256 checksum
How to use checksums
cbe1cc1cdd95cbc49418b628d94d2ae8d4304177b5bb2bf72d2ed749703c98a2
BLAKE2b-256 checksum
How to use checksums
ad39a54e3511ff35af28d2ebe3f354aefeb29d2799dee2788dd294e2620d3b19
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.9.0

Release files / embexpr-1.1.1-py2.py3-none-any.whl

Download URL embexpr-1.1.1-py2.py3-none-any.whl
Size 4.5 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
9acdd3e865c0aea735dc22d93d1c52adfce88e5fbca47eebf46f45fa5cccebbe
BLAKE2b-256 checksum
How to use checksums
02fc32aebe99fa852d4ca1bb9150ccef0d79e81578aebd734dee43c2629afe9f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.9.0

Release history Release notifications | RSS feed

This release

1.1.1 This release

2 release files

1.1.0

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page