def to_bool ( value ) : # type: (Any) -> bool if isinstance ( value , _compat . string_types ) : return value . upper ( ) in ( 'Y' , 'YES' , 'T' , 'TRUE' , '1' , 'OK' ) return bool ( value )
python change type from int to boolean
Convert a value into a bool but handle truthy strings eg yes true ok y
def to_bool(value):
    # type: (Any) -> bool
    """
    Convert a value into a bool but handle "truthy" strings eg, yes, true, ok, y
    """
    if isinstance(value, _compat.string_types):
        return value.upper() in ('Y', 'YES', 'T', 'TRUE', '1', 'OK')
    return bool(value)