回复: Columnize in module "cmd"

Tom Zhou pytom at yahoo.cn
Tue Dec 20 00:49:52 EST 2011


Thanks for your reply! But i think using "for at for@for" to find out the appropriate column size is also another waste,
on the other hand, the length of the list's single string is similar with each other usually, so the maximum maybe is the mode of the list.


________________________________
 发件人: Ian Kelly <ian.g.kelly at gmail.com>
收件人: Tom Zhou <pytom at yahoo.cn> 
抄送: "python-list at python.org" <python-list at python.org> 
发送日期: 2011年12月19日, 星期一, 下午 7:35
主题: Re: Columnize in module "cmd"
 
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20111220/97b3b6a7/attachment-0001.html>


More information about the Python-list mailing list