Last active
October 4, 2020 17:17
-
-
Save rhaleblian/a96d8839db87e734929de4dcd8e2f243 to your computer and use it in GitHub Desktop.
The Truth, the Whole Truth, and Nothing But the Truth.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import distutils.utils | |
def truth(s): | |
""" :return True|False|None: truth(iness) value. | |
:param object s: a value from os.environ.get(). | |
""" | |
if s in (True, False, None): | |
return s | |
if isinstance(s, int): | |
if s > 0: | |
return True | |
return False | |
if isinstance(s, float): | |
if s > 0: | |
return True | |
return False | |
return bool(distutils.util.strtobool(s)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment