Formatting a string to be a columned block of text
Dave Borne
dborne at gmail.com
Tue Dec 26 10:17:51 EST 2006
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 it. the "print '\n'"
line needs to be either
print ''
or
print '\n',
(with a comma)
-dave
More information about the Python-list
mailing list