def _str(s):
 try:
  if isinstance(s, unicode):
   return s.encode('utf-8', 'replace')
 except NameError:
  pass
 return s

def _str ( s ) : try : if isinstance ( s , unicode ) : return s . encode ( 'utf-8' , 'replace' ) except NameError : pass return s
wrap single quotes around strings .