def limited_join(sep, items, max_chars=30, overflow_marker='...'):
 full_str = sep.join(items)
 if (len(full_str) < max_chars):
  return full_str
 n_chars = 0
 n_items = 0
 for (j, item) in enumerate(items):
  n_chars += (len(item) + len(sep))
  if (n_chars < (max_chars - len(overflow_marker))):
   n_items += 1
  else:
   break
 return sep.join((list(items[:n_items]) + [overflow_marker]))

def limited_join ( sep , items , max_chars = 30 , overflow_marker = '...' ) : full_str = sep . join ( items ) if ( len ( full_str ) < max_chars ) : return full_str n_chars = 0 n_items = 0 for ( j , item ) in enumerate ( items ) : n_chars += ( len ( item ) + len ( sep ) ) if ( n_chars < ( max_chars - len ( overflow_marker ) ) ) : n_items += 1 else : break return sep . join ( ( list ( items [ : n_items ] ) + [ overflow_marker ] ) )
join a number of strings to one .