def bool_from_str(val):
 if (not val):
  return False
 try:
  return (True if int(val) else False)
 except ValueError:
  return (val.lower() == 'true')

def bool_from_str ( val ) : if ( not val ) : return False try : return ( True if int ( val ) else False ) except ValueError : return ( val . lower ( ) == 'true' )
convert a string representation of a bool into a bool value .