def make_boolean(value):
 value = str(value)
 value = value.lower().strip()
 if (value in ('true', 'false')):
  if (value == 'true'):
   return True
  return False
 try:
  ival = int(value)
  return bool(ival)
 except ValueError:
  pass
 if (value in ('+', '-')):
  if (value == '+'):
   return True
  return False
 if (value in ('on', 'off')):
  if (value == 'on'):
   return True
  return False
 raise TwillException(("unable to convert '%s' into true/false" % (value,)))

def make_boolean ( value ) : value = str ( value ) value = value . lower ( ) . strip ( ) if ( value in ( 'true' , 'false' ) ) : if ( value == 'true' ) : return True return False try : ival = int ( value ) return bool ( ival ) except ValueError : pass if ( value in ( '+' , '-' ) ) : if ( value == '+' ) : return True return False if ( value in ( 'on' , 'off' ) ) : if ( value == 'on' ) : return True return False raise TwillException ( ( "unable to convert '%s' into true/false" % ( value , ) ) )
convert the input value into a boolean like so: >> make_boolean true >> make_boolean false >> make_boolean(1) true >> make_boolean(0) false >> make_boolean(+) true >> make_boolean(-) false .