def cut_str(string, length, ellipsis='...'): if len(string) < length: return string return string[0:length-len(ellipsis)]+ellipsis