When using Python\'s textwrap library, how can I turn this:
short line, long line xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
How about wrap only lines longer then 90 characters?
new_body = "" lines = body.split("\n") for line in lines: if len(line) > 90: w = textwrap.TextWrapper(width=90, break_long_words=False) line = '\n'.join(w.wrap(line)) new_body += line + "\n"