Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #79212
| X-FeedAbuse | http://nntpfeed.proxad.net/abuse.pl feeded by 78.192.65.63 |
|---|---|
| Path | csiph.com!usenet.pasdenom.info!dedibox.gegeweb.org!gegeweb.eu!nntpfeed.proxad.net!news.muarf.org!news.roellig-ltd.de!open-news-network.org!cyclone02.ams2.highwinds-media.com!news.highwinds-media.com!voer-me.highwinds-media.com!lightspeed.eweka.nl!lightspeed.eweka.nl!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
| Return-Path | <ian.g.kelly@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.019 |
| X-Spam-Evidence | '*H*': 0.96; '*S*': 0.00; '16,': 0.03; 'elegant': 0.07; 'counting': 0.09; 'repeated': 0.09; 'strings.': 0.09; 'inclined': 0.16; 'url:html)': 0.16; 'wrote:': 0.18; 'library': 0.18; 'looked': 0.18; 'trying': 0.19; 'slightly': 0.19; 'thu,': 0.19; 'fit': 0.20; 'case.': 0.24; 'question': 0.24; 'suggested': 0.26; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'message- id:@mail.gmail.com': 0.30; 'url:python': 0.33; 'case,': 0.35; 'received:google.com': 0.35; 'url:org': 0.36; 'url:library': 0.38; 'to:addr:python-list': 0.38; 'list,': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; "you're": 0.61; 'first': 0.61; 'url:index': 0.63; 'more': 0.64; 'printing,': 0.74; 'counts': 0.83; 'contents,': 0.84; 'kennedy': 0.84 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; bh=zExoEq79t3xp+G5Gzh4zbZDUtKepx4PJTkrNNX9cpcs=; b=uVK5Imd0cuwuDCs//UpYVGIwzKZMQurqvTGMnYW3DcQnLsRkF8qJbnYLjXCuKjkWdZ VVneu8cI3/bevLjfvFyaI98vp3R0UF+WrMUTp0V98T4vJ/WU9zK145q+6ua2HvmU5Fix /VC7c2R7o/uN3biFVHForEkU9DPFNVBy2iDJ5hG23VwUlY68ZouOtr0A3KCyU33rEwW+ wz57k1p4RMHjhK3xnM4l1dL47Z0d1j5KX8CQuLBCvsgL81/hk/h7oMaU8k/ejj+cmbd9 4cqpOdMqrnDRec8uzuMArCpNq1IEzivGFOHS3/5J2fkTm645vd3e6B8MmCz50Btj+IAH yOBQ== |
| X-Received | by 10.66.252.193 with SMTP id zu1mr1420430pac.153.1413468306009; Thu, 16 Oct 2014 07:05:06 -0700 (PDT) |
| MIME-Version | 1.0 |
| In-Reply-To | <7490ed54-3116-45da-85d1-f9ce4bf29c5e@googlegroups.com> |
| References | <mailman.14888.1413398369.18130.python-list@python.org> <7490ed54-3116-45da-85d1-f9ce4bf29c5e@googlegroups.com> |
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Date | Thu, 16 Oct 2014 08:04:25 -0600 |
| Subject | Re: Creating a counter |
| To | Python <python-list@python.org> |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | quoted-printable |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://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 | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.14924.1413468316.18130.python-list@python.org> (permalink) |
| Lines | 15 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1413468316 news.xs4all.nl 2971 [2001:888:2000:d::a6]:36011 |
| X-Complaints-To | abuse@xs4all.nl |
| X-Received-Body-CRC | 3823142000 |
| X-Received-Bytes | 3996 |
| Xref | csiph.com comp.lang.python:79212 |
Show key headers only | View raw
On Thu, Oct 16, 2014 at 7:44 AM, Simon Kennedy <sffjunkie@gmail.com> wrote: > When you looked through the other answers and found a solution you're happy with that does not use the standard library you can look through the documentation and find a stdlib (https://docs.python.org/2.7/library/index.html) provided way that may be slightly more elegant for counting strings. I would have suggested a Counter if I thought it fit the OP's use case. If you're listing directory contents, you're not going to have any repeated strings, so all the counts will be 1, and your Counter might as well be a list, which is what you got from calling os.listdir() in the first place. So I was more inclined to think that the OP was only trying to count one thing. In any case, the question turned out to actually be about printing, not counting.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Creating a counter Shiva <shivaji_tn@yahoo.com> - 2014-10-15 18:39 +0000
Re: Creating a counter Simon Kennedy <sffjunkie@gmail.com> - 2014-10-16 06:44 -0700
Re: Creating a counter Ian Kelly <ian.g.kelly@gmail.com> - 2014-10-16 08:04 -0600
Re: Creating a counter Simon Kennedy <sffjunkie@gmail.com> - 2014-10-16 07:12 -0700
csiph-web