def _cast_boolean ( value ) : _BOOLEANS = { '1' : True , 'yes' : True , 'true' : True , 'on' : True , '0' : False , 'no' : False , 'false' : False , 'off' : False , '' : False } value = str ( value ) if value . lower ( ) not in _BOOLEANS : raise ValueError ( 'Not a boolean: %s' % value ) return _BOOLEANS [ value . lower ( ) ]
replace boolean values with 1s and 0s python
Helper to convert config values to boolean as ConfigParser do .
def _cast_boolean(value):
    """
    Helper to convert config values to boolean as ConfigParser do.
    """
    _BOOLEANS = {'1': True, 'yes': True, 'true': True, 'on': True,
                 '0': False, 'no': False, 'false': False, 'off': False, '': False}
    value = str(value)
    if value.lower() not in _BOOLEANS:
        raise ValueError('Not a boolean: %s' % value)

    return _BOOLEANS[value.lower()]