arithmetic-expressions
arithmetic-expression is a Python module for symbolic arithmetic expressions. It supports serialization,
deserialization, evaluation with custom variables, and an easy construction interface by combining existing
expressions.
It is built around Python's ast module and therefore uses Python syntax when string serializing and deserializing.
However, it only supports single-line expressions and strongly restricts the grammar when evaluating expressions.
This constrained subset of the grammar encompasses variables, numeric constants, unary and binary arithmetic
operators, comparison operators, the ternary if-else operator and selected function calls.
Expressions can be deserialized from strings, but can also be built from scratch with an intuitive API that aligns with Python's own syntax.
Example
from arithmetic_expressions import Expression
# Parse an expression
Expression.parse("x * 2 + 1")
# Or create it from scratch
expression = Expression("x") * 2 + 1
# String casting will serialize the expression
print(expression) # prints "x * 2 + 1"
# Pass variables to evaluate it
print(expression.evaluate(x=3)) # prints "7"
Metadata
Release files for arithmetic-expressions 0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| arithmetic_expressions-0.1.tar.gz | 4.5 kB | Without provenance | Details for arithmetic_expressions-0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| arithmetic_expressions-0.1-py3-none-any.whl | Python 3 | none | any | Details for arithmetic_expressions-0.1-py3-none-any.whl |
Total release size: 9.9 kB
Release files / arithmetic_expressions-0.1.tar.gz
| Download URL | arithmetic_expressions-0.1.tar.gz |
|---|---|
| Size | 4.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
229b48ff6a9a748f197e2f7d0c9a25658c3a950aa1f4b0a1a00fff105fad8ce0
|
|
BLAKE2b-256 checksum How to use checksums |
05d838a99464d2e45da8ad99411673e5bc7e81fcca20eb034192a0855a3fa083
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.7.1 CPython/3.11.6 Linux/6.5.0-4-amd64
|
Release files / arithmetic_expressions-0.1-py3-none-any.whl
| Download URL | arithmetic_expressions-0.1-py3-none-any.whl |
|---|---|
| Size | 5.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9ca6d6a087a790b64fdb642095b2e3ce0b34f6184f47f80c02dc81096288c12d
|
|
BLAKE2b-256 checksum How to use checksums |
09dcf94a61dde2799c6114fd6ae91de5fede9de98a9ad898927665370cf3c1fd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.7.1 CPython/3.11.6 Linux/6.5.0-4-amd64
|
Security for arithmetic-expressions 0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.