def SmartUnicode(string):
 if (type(string) != unicode):
  try:
   return string.__unicode__()
  except (AttributeError, UnicodeError):
   return str(string).decode('utf8', 'ignore')
 return string

def SmartUnicode ( string ) : if ( type ( string ) != unicode ) : try : return string . __unicode__ ( ) except ( AttributeError , UnicodeError ) : return str ( string ) . decode ( 'utf8' , 'ignore' ) return string
returns a unicode object .