Evaluate string Python conditions while keeping control on functions and variables accessible
Project description
string_conditions
Evaluate string Python conditions while keeping control on functions and variables accessible.
Usage
Python
from string_conditions import evaluate_condition
evaluate_condition(
condition="(year not in (2020,2021) and 10 > month > 4) or type.lower() == 'sometype'",
context={
'type': "SomeType",
'year': 2023,
'month': 6,
}
)
CLI
python -m string_conditions "(year > 2020 and type not in ('std', 'premium')) or message.lower().startswith('hello')" -c '{"year":2021, "type":"new", "message":"Hello World"}'
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file string_conditions-0.0.1.tar.gz.
File metadata
- Download URL: string_conditions-0.0.1.tar.gz
- Upload date:
- Size: 7.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bffe3e4d4193227e653ec653410ce01f7d8fe8db4710bb62fa1c516cd67e8f51
|
|
| MD5 |
3814bb0d2f88bbfc125e7d3d3fc28cea
|
|
| BLAKE2b-256 |
f65e301ce601e5e47faa76d725c83704349c8362c46789aadfdfcd918ee07745
|
File details
Details for the file string_conditions-0.0.1-py3-none-any.whl.
File metadata
- Download URL: string_conditions-0.0.1-py3-none-any.whl
- Upload date:
- Size: 8.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1807ee6bbd0c3442391b78764db21778af3a60d5e798fef42521470e4c3e1897
|
|
| MD5 |
43a00d70212322a130457062ff9c0181
|
|
| BLAKE2b-256 |
a3b8745e5476606d8d095cf47b47035d529c3b518c3717e55910b4c380fced88
|