Python module to format text into columns?

hamish_lawson at hamish_lawson at
Tue Nov 16 11:44:51 CET 1999

mlh at (Magnus L. Hetland) wrote:

> Without really knowing whether there is such a module, I offer a
> simple implementation of some of the functionality, which can easily
> be extended:

Holding to the principle of not reinventing the wheel, I decided to
search the Python archives and (if necessary) ask in this newsgroup
before attempting to write my own module. Now that it appears that no
such module already exists, your contribution, Magnus, has given me a
start in writing my own. Thank you.

The module could provide a format picture mechanism for specifying
column widths and alignments:

   formatter.setpicture("    <<<<<<<<<<<<<<<<  <<<<  >>>>>>")

but I'm inclined to provide (at least initially) just the direct

   formatter.setcolumn(column=1, margin=4, width=16, align=left)
   formatter.setcolumn(column=2, margin=2, width=4, align=left)
   formatter.setcolumn(column=3, margin=2, width=6, align=right)

Does anyone have any thoughts on this?

Hamish Lawson

Sent via
Before you buy.

More information about the Python-list mailing list