Formatting a string to be a columned block of text

2006-12-26 Thread Leon
Hi, I'm creating a python script that can take a string and print it to the screen as a simple multi-columned block of mono-spaced, unhyphenated text based on a specified character width and line hight for a column. For example, if i fed the script an an essay, it would format the text like a news

Re: Formatting a string to be a columned block of text

2006-12-26 Thread placid
Leon wrote: > Hi, > > I'm creating a python script that can take a string and print it to the > screen as a simple multi-columned block of mono-spaced, unhyphenated > text based on a specified character width and line hight for a column. > For example, if i fed the script an an essay, it would for

Re: Formatting a string to be a columned block of text

2006-12-26 Thread Paul McGuire
"Leon" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi, > > I'm creating a python script that can take a string and print it to the > screen as a simple multi-columned block of mono-spaced, unhyphenated > text based on a specified character width and line hight for a column. > For

Re: Formatting a string to be a columned block of text

2006-12-26 Thread Dave Borne
On 26 Dec 2006 04:14:27 -0800, Leon <[EMAIL PROTECTED]> wrote: > I'm creating a python script that can take a string and print it to the > screen as a simple multi-columned block of mono-spaced, unhyphenated > text based on a specified character width and line hight for a column. Hi, Leon, For pu

Re: Formatting a string to be a columned block of text

2006-12-26 Thread Dave Borne
Thanks, Paul. I didn't know about textwrap, that's neat. Leon, so in my example change > data1= [testdata[x:x+colwidth] for x in range(0,len(testdata),colwidth)] to > data1 = textwrap.wrap(testdata,colwidth) > data1 = [x.ljust(colwidth) for x in data1] oh and I made a mistake that double spaces i

Re: Formatting a string to be a columned block of text

2006-12-26 Thread Paul McGuire
"Paul McGuire" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > gettysburgAddress = """Four score and seven years ago... By the way, this variable contains only 3 (very long) lines of text, one for each paragraph. (Not immediately obvious after Usenet wraps the text.) -- Paul

Re: Formatting a string to be a columned block of text

2006-12-26 Thread Duncan Booth
"Paul McGuire" <[EMAIL PROTECTED]> wrote: > By the way, this variable contains only 3 (very long) lines of text, > one for each paragraph. (Not immediately obvious after Usenet wraps > the text.) Usenet doesn't wrap text, all it has is a convention which suggests that people posting to usenet sh

Re: Formatting a string to be a columned block of text

2006-12-26 Thread rzed
"Dave Borne" <[EMAIL PROTECTED]> wrote in news:[EMAIL PROTECTED]: > Thanks, Paul. I didn't know about textwrap, that's neat. > > Leon, > so in my example change >> data1= [testdata[x:x+colwidth] for x in >> range(0,len(testdata),colwidth)] > to >> data1 = textwrap.wrap(testdata,colwidth) >> dat