[Zope] wrapping email at 72 characters ?
Casey Duncan
casey@zope.com
Thu, 8 Aug 2002 08:43:57 -0400
Try this code from my MSWordMunger product (which predates Python 2.0 btw=
):
from string import find, rfind, join
def wordWrap(text, width):
remaining =3D text
wrapped =3D []
while len(remaining) > width:
cut =3D width
if remaining[cut] !=3D ' ':
cut =3D rfind(remaining, ' ', 0, cut-1)
if cut =3D=3D -1: cut =3D find(remaining, ' ', cut-1)
if cut =3D=3D -1: cut =3D len(remaining)
wrapped.append(remaining[:cut])
remaining =3D remaining[cut+1:]
if remaining:
wrapped.append(remaining)
return join(wrapped, '\n')
hth,
Casey
On Thursday 08 August 2002 07:40 am, Geir B=E6kholt wrote:
> Does anyone have a python snippet or something that helps format
> outgoing emails, so that lines wrap nicely at 72 characters?
>=20
> :)
>=20
>=20
> --=20
> Geir B=E6kholt web-developer
> geirh@funcom.com funcom oslo | webdev-team
>=20
>=20
> _______________________________________________
> 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 )
>=20