def _flatten_params(params):
 def get_string(value):
  if isinstance(value, unicode):
   return unicode(value).encode('utf-8')
  else:
   return str(value)
 param_list = []
 for (key, value) in params.iteritems():
  key = get_string(key)
  if isinstance(value, basestring):
   param_list.append((key, get_string(value)))
  else:
   try:
    iterator = iter(value)
   except TypeError:
    param_list.append((key, str(value)))
   else:
    param_list.extend(((key, get_string(v)) for v in iterator))
 return param_list

def _flatten_params ( params ) : def get_string ( value ) : if isinstance ( value , unicode ) : return unicode ( value ) . encode ( 'utf-8' ) else : return str ( value ) param_list = [ ] for ( key , value ) in params . iteritems ( ) : key = get_string ( key ) if isinstance ( value , basestring ) : param_list . append ( ( key , get_string ( value ) ) ) else : try : iterator = iter ( value ) except TypeError : param_list . append ( ( key , str ( value ) ) ) else : param_list . extend ( ( ( key , get_string ( v ) ) for v in iterator ) ) return param_list
converts a dictionary of parameters to a list of parameters .