def SmartStr(string):
 if (type(string) == unicode):
  return string.encode('utf8', 'ignore')
 return str(string)

def SmartStr ( string ) : if ( type ( string ) == unicode ) : return string . encode ( 'utf8' , 'ignore' ) return str ( string )
returns a string or encodes a unicode object .