Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 truncating a string and adding ellipses
in a set of functions i am writing there is one that outputs a name and data value given to it. the name usually a string and the data is often a string. or it might be some huge object. it tries to print them on one line. if they don't fit, it truncates the output line, which means it is no longer viable as python syntax. if truncated i append "..." with that truncation being 3 more characters so it fits. it also means no quote is printed since the truncation applies the line after repr() or !r in f-stribgs has inclode quotes.

what i wonder is if i should insert a closing quote when truncated or just not worry about it. a like might look like:

this example truncates at column 24:
code to make the final form might look lik:
if len(out)>width:
if the above output is not good enough, how should it be?
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.

Top Page

Forum Jump:

Users browsing this thread: 1 Guest(s)