Try this code from my MSWordMunger product (which predates Python 2.0 btw): from string import find, rfind, join def wordWrap(text, width): remaining = text wrapped = [] while len(remaining) > width: cut = width if remaining[cut] != ' ': cut = rfind(remaining, ' ', 0, cut-1) if cut == -1: cut = find(remaining, ' ', cut-1) if cut == -1: cut = len(remaining) wrapped.append(remaining[:cut]) remaining = remaining[cut+1:] if remaining: wrapped.append(remaining) return join(wrapped, '\n') hth, Casey On Thursday 08 August 2002 07:40 am, Geir Bækholt wrote:
Does anyone have a python snippet or something that helps format outgoing emails, so that lines wrap nicely at 72 characters?
:)
-- Geir Bækholt web-developer geirh@funcom.com funcom oslo | webdev-team
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )