Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #17645 > unrolled thread

Re: [Python-ideas] 回复: Columnize in module "cmd"

Started byMRAB <python@mrabarnett.plus.com>
First post2011-12-21 04:30 +0000
Last post2011-12-21 04:30 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [Python-ideas] 回复:  Columnize in module "cmd" MRAB <python@mrabarnett.plus.com> - 2011-12-21 04:30 +0000

#17645 — Re: [Python-ideas] 回复: Columnize in module "cmd"

FromMRAB <python@mrabarnett.plus.com>
Date2011-12-21 04:30 +0000
SubjectRe: [Python-ideas] 回复: Columnize in module "cmd"
Message-ID<mailman.3899.1324441825.27778.python-list@python.org>
On 21/12/2011 03:28, Tom Zhou wrote:
> 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.
>
A couple of points:

1. Trying not to use the names of built-in classes or functions for
your variable names, for example "list".

2. In Python 2 int/int returns an int, but in Python 3 int/int returns
a float. In both cases int//int returns an int (at least for recent
versions of Python 2), so it's a good idea to always use // when you
want to do integer division.

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web