def decode_factory(text):
 if isinstance(text, str):
  return unicoder(text)
 elif isinstance(text, list):
  new_text = []
  for t in text:
   new_text.append(decode_factory(t))
  return new_text
 elif isinstance(text, dict):
  new_text = {}
  for key in text:
   new_text[key] = decode_factory(text[key])
  return new_text
 else:
  return text

def decode_factory ( text ) : if isinstance ( text , str ) : return unicoder ( text ) elif isinstance ( text , list ) : new_text = [ ] for t in text : new_text . append ( decode_factory ( t ) ) return new_text elif isinstance ( text , dict ) : new_text = { } for key in text : new_text [ key ] = decode_factory ( text [ key ] ) return new_text else : return text
recursively looks through the supplied argument and converts and text to unicode .