code: 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()]
docs: Helper to convert config values to boolean as ConfigParser do.