[Python-ideas] 回复: Columnize in module "cmd"
Tom Zhou
pytom at yahoo.cn
Wed Dec 21 04:28:54 CET 2011
More information about the Python-ideas mailing list
Wed Dec 21 04:28:54 CET 2011
- Previous message: [Python-ideas] Columnize in module "cmd"
- Next message: [Python-ideas] defaultattrgetter
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Thanks a lot for your reply! I've reservations, maybe code looks like: """ colwidth = max(map(len, list)) ncols = displaywidth/(colwidth+2)+1 nrows = size/ncols+1 for nrows for ncols texts = list[...] output texts """ is clear, and just waste some space of stdout. --- Best Regards tom ________________________________ 发件人: Guido van Rossum <guido at python.org> 收件人: Tom Zhou <pytom at yahoo.cn> 抄送: "python-ideas at python.org" <python-ideas at python.org> 发送日期: 2011年12月20日, 星期二, 上午 7:14 主题: Re: [Python-ideas] Columnize in module "cmd" That code is trying to find an optimal solution where the columns may be of different width. Good luck! --Guido On Mon, Dec 19, 2011 at 8:07 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. > > > > >--- >thankstom > > >_______________________________________________ >Python-ideas mailing list >Python-ideas at python.org >http://mail.python.org/mailman/listinfo/python-ideas > > -- --Guido van Rossum (python.org/~guido) -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-ideas/attachments/20111221/45978a9e/attachment.html>
- Previous message: [Python-ideas] Columnize in module "cmd"
- Next message: [Python-ideas] defaultattrgetter
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-ideas mailing list