A Python package for evaluating multiple boolean conditions (uses eval) IN ORDER.
Project description
py_eio_logic
A simple Python package for evaluating multiple boolean conditions provided as strings.
WARNING: This package uses eval() internally. It is EXTREMELY DANGEROUS to use this package with UNTRUSTED INPUT STRINGS. Malicious input can lead to arbitrary code execution on your system.
Please ensure all conditions passed to eio() are from trusted, internal sources only.
Installation
pip install py-eio
from py_eio import eio
# Example 1: Passing individual condition strings
x = 10
y = 5
result = eio("x > 5", "y < 10")
print(f"Result 1: {result}") # Expected: True
result = eio("x == 10", "y == 6")
print(f"Result 2: {result}") # Expected: False
# Example 2: Passing a list of condition strings
z = 7
conditions_list = ["z >= 7", "x + y == 15"]
result = eio(conditions_list)
print(f"Result 3: {result}") # Expected: True
conditions_list_fail = ["z < 5", "x > 0"]
result = eio(conditions_list_fail)
print(f"Result 4: {result}") # Expected: False
# Example 3: When no conditions are passed (evaluates to True)
result = eio()
print(f"Result 5: {result}") # Expected: True
from py_eio import eio
# 'undefined_var' does not exist.
# The second condition would cause a NameError if evaluated.
# Case 1: Error condition is after a False condition
result = eio("1 == 2", "undefined_var > 0")
print(f"Result with error condition after False: {result}")
# Output: Result with error condition after False: False
# (No error message for 'undefined_var' because "1 == 2" is False, and evaluation stops)
# Case 2: Error condition is the first one, or after a True condition
# This will print an error message from the function (due to the try-except block)
# and return None.
result = eio("1 == 1", "another_undefined_var > 0")
print(f"Result with error condition evaluated: {result}")
# Output: Error evaluating condition 'another_undefined_var > 0': name 'another_undefined_var' is not defined
# Result with error condition evaluated: None
git clone [https://github.com/MostafaHanii/py_eio.git](https://github.com/MostafaHanii/py_eio.git)
cd py_eio
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -e .
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
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 py_eval_in_order-0.1.0.tar.gz.
File metadata
- Download URL: py_eval_in_order-0.1.0.tar.gz
- Upload date:
- Size: 4.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8241bfc81f84fa7184ee9197aa77f6f75a366821e8e875e481fcea35e5a1a6d6
|
|
| MD5 |
23263ba42fa3943f7ac2e1b66bdb03a8
|
|
| BLAKE2b-256 |
8d0a444c97a0a5879abe071427a2e85dd91fd4c3297be219eb96a0d960ec59fa
|
File details
Details for the file py_eval_in_order-0.1.0-py3-none-any.whl.
File metadata
- Download URL: py_eval_in_order-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
300e4638bbb7ca5b19acb5ffae638e552bdf60b3cef645730cf044c7940513dc
|
|
| MD5 |
a35cabc19b7cf3aa03b840bb7a5a5fa0
|
|
| BLAKE2b-256 |
c681b7c13b50c59691e28da8010f747e32c874287a8ac6b7704a190c4661a012
|