Re: format string to certain line width

2008-08-13 Thread John Machin
On Aug 13, 10:13 pm, [EMAIL PROTECTED] wrote: > import textwrap > print textwrap.fill("HelloWorld", 2) > > He > > ll > > oW > > or > > ld > > > Of course if your assertion that the string contains no spaces, tabs or > > newlines turns out to be incorrect this may not do what you wanted. >

Re: format string to certain line width

2008-08-13 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: Thanks, i just found this myself and it works fine, but very slow... The script without the wrapping takes 30 seconds, with wrapping 30 minutes. Is there not a more efficient way? sounds like you're wrapping a few million long strings, not just one... here are two app

Re: format string to certain line width

2008-08-13 Thread elukkien
import textwrap print textwrap.fill("HelloWorld", 2) > He > ll > oW > or > ld > > Of course if your assertion that the string contains no spaces, tabs or > newlines turns out to be incorrect this may not do what you wanted. Thanks, i just found this myself and it works fine, but very slo

Re: format string to certain line width

2008-08-13 Thread Duncan Booth
[EMAIL PROTECTED] wrote: > I'm trying to find a way to print out a long string (>400 characters > no spaces, tabs or newlines) to a line width of 60 characters. So > after every 60 characters a newline would start. Is it possible to > transform the string to set the linewidth? > > for example for

format string to certain line width

2008-08-13 Thread elukkien
Hello! I'm trying to find a way to print out a long string (>400 characters no spaces, tabs or newlines) to a line width of 60 characters. So after every 60 characters a newline would start. Is it possible to transform the string to set the linewidth? for example for a linewidth of 2: >>>str = "