def parse_qsl(qs, keep_blank_values=0, strict_parsing=0):
 pairs = [s2 for s1 in qs.split('&') for s2 in s1.split(';')]
 r = []
 for name_value in pairs:
  if ((not name_value) and (not strict_parsing)):
   continue
  nv = name_value.split('=', 1)
  if (len(nv) != 2):
   if strict_parsing:
    raise ValueError, ('bad query field: %r' % (name_value,))
   if keep_blank_values:
    nv.append('')
   else:
    continue
  if (len(nv[1]) or keep_blank_values):
   name = unquote(nv[0].replace('+', ' '))
   value = unquote(nv[1].replace('+', ' '))
   r.append((name, value))
 return r

def parse_qsl ( qs , keep_blank_values = 0 , strict_parsing = 0 ) : pairs = [ s2 for s1 in qs . split ( '&' ) for s2 in s1 . split ( ';' ) ] r = [ ] for name_value in pairs : if ( ( not name_value ) and ( not strict_parsing ) ) : continue nv = name_value . split ( '=' , 1 ) if ( len ( nv ) != 2 ) : if strict_parsing : raise ValueError , ( 'bad query field: %r' % ( name_value , ) ) if keep_blank_values : nv . append ( '' ) else : continue if ( len ( nv [ 1 ] ) or keep_blank_values ) : name = unquote ( nv [ 0 ] . replace ( '+' , ' ' ) ) value = unquote ( nv [ 1 ] . replace ( '+' , ' ' ) ) r . append ( ( name , value ) ) return r
parse a query given as a string argument .