This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author otto
Recipients BreamoreBoy, georg.brandl, gvanrossum, gward, jerith, mark.dickinson, mrabarnett, otto, palfrey, terry.reedy, tlynn
Date 2012-04-12.06:47:39
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1334213259.89.0.217113131317.issue1859@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2012-04-12 06:47:40ottosetrecipients: + otto, gvanrossum, gward, georg.brandl, terry.reedy, mark.dickinson, tlynn, palfrey, jerith, mrabarnett, BreamoreBoy
2012-04-12 06:47:39ottosetmessageid: <1334213259.89.0.217113131317.issue1859@psf.upfronthosting.co.za>
2012-04-12 06:47:39ottolinkissue1859 messages
2012-04-12 06:47:39ottocreate