def encode_params_utf8(params):
 encoded = []
 for (k, v) in params:
  encoded.append(((k.encode('utf-8') if isinstance(k, unicode) else k), (v.encode('utf-8') if isinstance(v, unicode) else v)))
 return encoded

def encode_params_utf8 ( params ) : encoded = [ ] for ( k , v ) in params : encoded . append ( ( ( k . encode ( 'utf-8' ) if isinstance ( k , unicode ) else k ) , ( v . encode ( 'utf-8' ) if isinstance ( v , unicode ) else v ) ) ) return encoded
ensures that all parameters in a list of 2-element tuples are encoded to bytestrings using utf-8 .