Columnize in module "cmd"

Ian Kelly ian.g.kelly at gmail.com
Mon Dec 19 22:35:23 EST 2011


On Mon, Dec 19, 2011 at 7:53 PM, Tom Zhou <pytom at yahoo.cn> wrote:
> Hi~ alls
> recently, i focus on the module "cmd", and find some confused things-- the
> function named "columnize". Why we need a multiloop as
> "for nrows ..
>         for col ..
>                    for row.."
> ?? i think we can make a easier method, for example, first, find out the
> maxlen str in list, and use its length as the standard size to format the
> list.
> Ok, maybe i ignore something, so please give me some hints.

The columns can have different widths.  Finding the single longest
string in the list and using its length for all columns would
potentially waste a lot of space.



More information about the Python-list mailing list