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
ifcollector-0.0.1.tar.gz
(3.3 kB
view hashes)
Built Distribution
Close
Hashes for ifcollector-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f6391f3b5d047c2a3447a2b36695bca9f2acbbad67e017d91fa0ae8ffebb60d1 |
|
MD5 | 32db147a4f88e8ca7c0227035fcc1888 |
|
BLAKE2b-256 | 3632fec0240ca0b53d505bccd494835c6a61237652bf779ca43edd5772fa8eb2 |