def set_query_params(url, param_dict):
 (scheme, netloc, path, query_string, fragment) = urlsplit(url)
 query_params = parse_qs(query_string, keep_blank_values=True)
 for (param_name, param_value) in param_dict.items():
  if (param_value is None):
   del query_params[param_name]
  else:
   query_params[param_name] = [param_value]
 new_query_string = urlencode(query_params, doseq=True)
 return urlunsplit((scheme, netloc, path, new_query_string, fragment))

def set_query_params ( url , param_dict ) : ( scheme , netloc , path , query_string , fragment ) = urlsplit ( url ) query_params = parse_qs ( query_string , keep_blank_values = True ) for ( param_name , param_value ) in param_dict . items ( ) : if ( param_value is None ) : del query_params [ param_name ] else : query_params [ param_name ] = [ param_value ] new_query_string = urlencode ( query_params , doseq = True ) return urlunsplit ( ( scheme , netloc , path , new_query_string , fragment ) )
given a url .