[Python-Dev] Where to put wrap_text()?

Barry A. Warsaw barry@zope.com
Sat, 1 Jun 2002 11:55:23 -0400


>>>>> "GW" == Greg Ward <gward@python.net> writes:

    GW> Proposal: a new standard library module, wrap_text, which
    GW> combines the best of distutils.fancy_getopt.wrap_text() and
    GW> Text::Wrap.  Right now, I'm thinking of an interface something
    GW> like this:

You might consider a text package with submodules for various wrapping
algorithms.  The text package might even grow other functionality
later too.

I say this because in Mailman I also have a wrap() function (big
surprise, eh?) that implements the Python FAQ wizard rules for
wrapping:

def wrap(text, column=70, honor_leading_ws=1):
    """Wrap and fill the text to the specified column.

    Wrapping is always in effect, although if it is not possible to wrap a
    line (because some word is longer than `column' characters) the line is
    broken at the next available whitespace boundary.  Paragraphs are also
    always filled, unless honor_leading_ws is true and the line begins with
    whitespace.  This is the algorithm that the Python FAQ wizard uses, and
    seems like a good compromise.
    """

There's nothing at all Mailman specific about it, so I wouldn't mind
donating it to the standard library.

-Barry