Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #79212
| 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 | 2014-10-16 08:04 -0600 |
| Subject | Re: Creating a counter |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.14924.1413468316.18130.python-list@python.org> (permalink) |
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