def unicodify(s, encoding='utf8', *args):
  """ because {str,unicode}.{encode,decode} is anti-polymorphic, but sometimes
  you can't control which you have. """
  if isinstance(s,unicode): return s
  if isinstance(s,str): return s.decode(encoding, *args)
  return unicode(s)
 because {str,unicode}.{encode,decode} is anti-polymorphic, but sometimes
  you can't control which you have. 
recipes/Python/576784_WSGI_optiparsing__type/recipe-576784.py