Getting Started
Install¶
1 2 3 4 5 | |
Introduction¶
General purpose bool/boolean utilities, extracting bools from strings.
bool_value function¶
Converts any object to a bool.
Special-cases strings, which bool is returned is based on string contents.
1 2 3 4 5 | |
Generally, if the value passed in is one of these, it's considered True:
- For Strings (after stripping any leading/training white-space):
- "t"
- "True"
- "T"
- "1"
- "true"
- "on"
- For
bool:- We simply return whatever the passed-in bool is.
- Other Types Of Objects:
- If object is True-like (where object's
__bool__()value is True).
- If object is True-like (where object's
Otherwise, a False will be returned (ie: if string contains 'false', we return False).
If any ValueError is raised while trying to get bool-value from any object,
will return False.
Examples¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | |
bool_env¶
Looks up environmental variable with passed in name.
Runs the env-var value though bool_value for you and returns the result.
Useful to easily get a bool-value from an environmental variable.
1 2 3 4 5 6 7 8 9 | |
Last update:
2023-12-20