code: def dict_encode(in_dict):
      
      if _IS_PY2:
          out_dict = {}
          for k, v in list(in_dict.items()):
              if isinstance(v, unicode):
                  v = v.encode('utf8')
              elif isinstance(v, str):
                  # Must be encoded in UTF-8
                  v.decode('utf8')
              out_dict[k] = v
          return out_dict
      else:
          raise NotImplementedError
docs: returns a new dictionary with encoded values useful for encoding http queries (python < 3)