def as_bool(value):
    if isinstance(value, bool):
        return value
    value = value.strip().lower()
    if value in ('y', 'yes', 'on', 't', 'true', '1'):
        return True
    if value in ('n', 'no', 'off', 'f', 'false', '0'):
        return False
    raise ValueError('Unrecognised value for bool: %r' % value)
Smart cast value to bool
dataset/ETHPy150Open funkybob/django-classy-settings/cbs/utils.py/as_bool