Message158106
As a note to comments msg60038-msg60040, for anybody like me who ended up here after Googling around on how to do wordwrap in Python:
The function textwrap in Python is for single strings/paragraphs only, and it does not work as wordwrap normally works in text editors or other programming languages (eg. Wordwrap in Python).
If you want to do wordwrap or a block of text, run something like this:
new_msg = ""
lines = msg.split("\n")
for line in lines:
if len(line) > 75:
w = textwrap.TextWrapper(width=75, break_long_words=False)
line = '\n'.join(w.wrap(line))
new_msg += line + "\n"
An use case example for this would be, if you have a email message and you want to apply word wrapping to it, so that no line would be over 78 characters. |
|
Date |
User |
Action |
Args |
2012-04-12 06:47:40 | otto | set | recipients:
+ otto, gvanrossum, gward, georg.brandl, terry.reedy, mark.dickinson, tlynn, palfrey, jerith, mrabarnett, BreamoreBoy |
2012-04-12 06:47:39 | otto | set | messageid: <1334213259.89.0.217113131317.issue1859@psf.upfronthosting.co.za> |
2012-04-12 06:47:39 | otto | link | issue1859 messages |
2012-04-12 06:47:39 | otto | create | |
|