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


Groups > comp.lang.python > #17645

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

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python@mrabarnett.plus.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'subject:: [': 0.02; '(at': 0.03; 'subject:module': 0.04; 'subject:Python': 0.05; '"""': 0.07; 'python': 0.08; 'from:addr:python': 0.09; 'subject:ideas': 0.09; 'output': 0.10; 'from:addr:mrabarnett.plus.com': 0.16; 'from:name:mrab': 0.16; 'message-id:@mrabarnett.plus.com': 0.16; 'points:': 0.16; 'received:84.92': 0.16; 'received:84.92.122': 0.16; 'received:84.92.122.60': 0.16; 'received:84.93': 0.16; 'received:84.93.230': 0.16; 'reply-to:addr:python-list': 0.16; 'wrote:': 0.18; 'int': 0.18; 'trying': 0.21; 'maybe': 0.21; 'header:In-Reply-To:1': 0.22; 'versions': 0.23; 'int,': 0.23; 'code': 0.25; 'classes': 0.26; 'variable': 0.28; 'looks': 0.29; 'example': 0.29; 'clear,': 0.30; 'float.': 0.30; 'least': 0.30; 'thanks': 0.31; "i've": 0.31; 'cases': 0.32; 'subject:]': 0.32; 'idea': 0.32; 'header:User-Agent:1': 0.33; 'to:addr:python-list': 0.34; 'received:84': 0.34; 'integer': 0.34; 'reply- to:addr:python.org': 0.34; 'but': 0.37; 'some': 0.38; 'couple': 0.38; "it's": 0.40; 'to:addr:python.org': 0.40; 'your': 0.61; 'header:Reply-To:1': 0.71; 'reply-to:no real name:2**0': 0.72; 'texts': 0.73; 'subjectcharset:utf-8': 0.73; 'reply!': 0.84
X-CM-Score 0.00
X-CNFS-Analysis v=2.0 cv=J8QoHXbS c=1 sm=1 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=9jsOeB20M3cA:10 a=2dp0JJIffCcA:10 a=jPJDawAOAc8A:10 a=OUOv7kDek9cA:10 a=IkcTkHD0fZMA:10 a=Zy06JUaY4F7lHWGDriwA:9 a=QEXdDO2ut3YA:10 a=0nF1XD0wxitMEM03M9B4ZQ==:117
X-AUTH mrabarnett:2500
Date Wed, 21 Dec 2011 04:30:51 +0000
From MRAB <python@mrabarnett.plus.com>
User-Agent Mozilla/5.0 (Windows NT 5.1; rv:8.0) Gecko/20111105 Thunderbird/8.0
MIME-Version 1.0
To python-list@python.org
Subject Re: [Python-ideas] 回复: Columnize in module "cmd"
References <1324349593.51908.YahooMailNeo@web92411.mail.cnh.yahoo.com> <1324350440.30993.YahooMailNeo@web92413.mail.cnh.yahoo.com> <CAP7+vJL9RRUCKhuqA7T6OLSJOsjtc9p74Yk7fwHrxwh=VJDfuw@mail.gmail.com> <1324438134.11446.YahooMailNeo@web92408.mail.cnh.yahoo.com>
In-Reply-To <1324438134.11446.YahooMailNeo@web92408.mail.cnh.yahoo.com>
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding 7bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
Reply-To python-list@python.org
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.3899.1324441825.27778.python-list@python.org> (permalink)
Lines 23
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1324441825 news.xs4all.nl 6853 [2001:888:2000:d::a6]:52190
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:17645

Show key headers only | View raw


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.

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

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

csiph-web