def clip_string(s, limit=1000, sep=None):
 if (len(s) < limit):
  return s
 s = s[:(limit - 3)]
 if (sep is None):
  return s
 sep_pos = s.rfind(sep)
 if (sep_pos == (-1)):
  return s
 return (s[:(sep_pos + len(sep))] + '...')

def clip_string ( s , limit = 1000 , sep = None ) : if ( len ( s ) < limit ) : return s s = s [ : ( limit - 3 ) ] if ( sep is None ) : return s sep_pos = s . rfind ( sep ) if ( sep_pos == ( - 1 ) ) : return s return ( s [ : ( sep_pos + len ( sep ) ) ] + '...' )
clip a string at a given character and add " .