A framework for creating complex if statements.
Project description
ifcollector
A framework for creating complex if statements.
pip3 install ifcollector
How to
With ifcollector, if statements can be created from lists. For complex if statements, stating all your conditionals in a list has the advantage of making code more readable and reuseable.
To use it, create a list with all the conditionals that will be evaluated against a single value. The conditionals can be a function, a boolean expression in the form of a string, or a lambda. For all boolean expressions and lamdas, the keyword value will be used for the variable being evaluated.
def matches_email_regex(value):
match_object = search(r'^(\w|\.|\_|\-)+[@](\w|\_|\-|\.)+[.]\w{2,3}$',
value)
return bool(match_object)
is_valid_gmail = [
"len(value) > 5",
"'@' in value",
matches_email_regex,
"'gmail.com' in value"
]
my_email = "jeff.gruenbaum@gmail.com"
if ifandstatement(my_email, *is_valid_gmail):
print("The email is valid!")
Output:
The email is valid!
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
File details
Details for the file ifcollector-0.0.1.tar.gz
.
File metadata
- Download URL: ifcollector-0.0.1.tar.gz
- Upload date:
- Size: 3.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b0604ce3e09915079f6667a7eaf6204f3becc45e4ca6a3deafcfb2fadce10fde |
|
MD5 | 9a91b731c8a8403ae9ef49c78b7d41f4 |
|
BLAKE2b-256 | 29e97c9fe54943d2c76c2ab7ea71e57d1d0d20d99d9372e317b907b48a7be6e6 |
File details
Details for the file ifcollector-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: ifcollector-0.0.1-py3-none-any.whl
- Upload date:
- Size: 3.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f6391f3b5d047c2a3447a2b36695bca9f2acbbad67e017d91fa0ae8ffebb60d1 |
|
MD5 | 32db147a4f88e8ca7c0227035fcc1888 |
|
BLAKE2b-256 | 3632fec0240ca0b53d505bccd494835c6a61237652bf779ca43edd5772fa8eb2 |