def parse_boolean(value):
 if (value in [u'true', u'1']):
  return True
 elif (value in [u'false', u'0']):
  return False
 else:
  raise ValueError((u"expected 'true' or 'false', got '%s'" % value))

def parse_boolean ( value ) : if ( value in [ u'true' , u'1' ] ) : return True elif ( value in [ u'false' , u'0' ] ) : return False else : raise ValueError ( ( u"expected 'true' or 'false', got '%s'" % value ) )
parses strings into booleans using the following mapping : true => true false => false 1 => true 0 => false .