def _convert_2_string(item):
 if isinstance(item, dict):
  return dict(((_convert_2_string(key), _convert_2_string(value)) for (key, value) in item.iteritems()))
 elif isinstance(item, list):
  return [_convert_2_string(i) for i in item]
 elif isinstance(item, tuple):
  return tuple([_convert_2_string(i) for i in item])
 elif isinstance(item, set):
  return item
 else:
  try:
   return item.encode('utf-8')
  except AttributeError:
   return str(item)

def _convert_2_string ( item ) : if isinstance ( item , dict ) : return dict ( ( ( _convert_2_string ( key ) , _convert_2_string ( value ) ) for ( key , value ) in item . iteritems ( ) ) ) elif isinstance ( item , list ) : return [ _convert_2_string ( i ) for i in item ] elif isinstance ( item , tuple ) : return tuple ( [ _convert_2_string ( i ) for i in item ] ) elif isinstance ( item , set ) : return item else : try : return item . encode ( 'utf-8' ) except AttributeError : return str ( item )
return byte strings for all items .