def parse_bool(value):
    """Parse a bool-like string or number in a reasonable way.

    Integer strings are converted to an integer before converting to a
    bool; case-insensitive variants of True and False are handled
    appropriately. Other values raise a ValueError.
    """
    try:
        return bool(int(value))
    except ValueError:
        lowercase = value.lower()
        if lowercase == 'true':
            return True
        elif lowercase == 'false':
            return False
        raise ValueError('Unable to parse {} as a bool'.format(value))