Otto Kekäläinen <[email protected]> added the comment:
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.
----------
nosy: +otto
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue1859>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com