def boolify(value):
""" Function that will translate common strings into bool values
True -> "True", "t", "yes", "y", "on", "1"
False -> any other string
Objects other than string will be transformed
using built-in bool() function.
"""
if isinstance(value, basestring):
try:
return bool(strtobool(value))
except ValueError:
return False
else:
return bool(value)
评论列表
文章目录