[issue1696199] Add collections.counts()

2009-01-12 Thread Raymond Hettinger
Raymond Hettinger added the comment: Thanks for the review comments. Incorporated all suggested changes and did some other minor tidying-up. Extended the update example to include c.update(Counter('abcdee')). Committed as r68559 . Decided to leave __repr__() with a sort. Though it's not str

[issue1696199] Add collections.counts()

2009-01-12 Thread Guido van Rossum
Changes by Guido van Rossum : -- nosy: -gvanrossum ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://ma

[issue1696199] Add collections.counts()

2009-01-12 Thread Georg Brandl
Georg Brandl added the comment: Attaching new patch with small changes: * Don't describe a class with "Returns ..." as if it was a function. * Indent interposed paragraphs so that the method descriptions still belong to the .. class directive. * Fixed Ned's typo. * Note that elements() and most

[issue1696199] Add collections.counts()

2009-01-12 Thread Ned Deily
Ned Deily added the comment: In counter6.diff line 56 "Assigning a count of zero or reducing the count to the zero leaves the" suggest s/the zero/zero/ -- nosy: +nad ___ Python tracker

[issue1696199] Add collections.counts()

2009-01-12 Thread Steven Bethard
Steven Bethard added the comment: The whole point was to have a function (or class) that accumulates a sequence and counts it. collections.defaultdict(lambda: 0) doesn't achieve this on its own because it only knows how to handle sequences of (key, value): >>> d = collections.defaultdict(lambda

[issue1696199] Add collections.counts()

2009-01-12 Thread Amaury Forgeot d'Arc
Amaury Forgeot d'Arc added the comment: > the typical usage is c=Counter(myseq) with no other non-dict accesses > (mostly just c[elem]+=1 and print c[elem]) Isn't collections.defaultdict(lambda:0) enough for this purpose? -- nosy: +amaury.forgeotdarc __

[issue1696199] Add collections.counts()

2009-01-12 Thread Raymond Hettinger
Changes by Raymond Hettinger : Removed file: http://bugs.python.org/file12695/counter5.diff ___ Python tracker ___ ___ Python-bugs-list mail

[issue1696199] Add collections.counts()

2009-01-12 Thread Raymond Hettinger
Changes by Raymond Hettinger : Removed file: http://bugs.python.org/file12671/counter4.diff ___ Python tracker ___ ___ Python-bugs-list mail

[issue1696199] Add collections.counts()

2009-01-12 Thread Raymond Hettinger
Raymond Hettinger added the comment: Attaching an update with improved docs. Thanks for looking at this. Added file: http://bugs.python.org/file12702/counter6.diff ___ Python tracker ___

[issue1696199] Add collections.counts()

2009-01-12 Thread Georg Brandl
Georg Brandl added the comment: Yes, I'll have a look this evening. ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: h

[issue1696199] Add collections.counts()

2009-01-12 Thread Raymond Hettinger
Raymond Hettinger added the comment: Georg, could you give this a once over before I commit? Thanks. -- assignee: rhettinger -> georg.brandl nosy: +georg.brandl Added file: http://bugs.python.org/file12695/counter5.diff ___ Python tracker

[issue1696199] Add collections.counts()

2009-01-09 Thread Raymond Hettinger
Changes by Raymond Hettinger : Removed file: http://bugs.python.org/file12665/counter3.diff ___ Python tracker ___ ___ Python-bugs-list mail

[issue1696199] Add collections.counts()

2009-01-09 Thread Raymond Hettinger
Changes by Raymond Hettinger : Added file: http://bugs.python.org/file12671/counter4.diff ___ Python tracker ___ ___ Python-bugs-list mailin

[issue1696199] Add collections.counts()

2009-01-09 Thread Raymond Hettinger
Raymond Hettinger added the comment: The counts/counter moniker emerged from the python-dev discussion and I'm basically happy with it since the typical usage is c=Counter(myseq) with no other non-dict accesses (mostly just c[elem]+=1 and print c[elem]). It's a simple counter with a dict interf

[issue1696199] Add collections.counts()

2009-01-09 Thread Antoine Pitrou
Antoine Pitrou added the comment: Some comments: - Counter sounds like a really strange name for a container. Why not call it "Bag" or "Multiset" (or "CountingSet"?) - why are the unittests inline rather than in Lib/test? inline tests don't get executed by the buildbots, nor by people running th

[issue1696199] Add collections.counts()

2009-01-09 Thread Raymond Hettinger
Changes by Raymond Hettinger : Removed file: http://bugs.python.org/file12664/counter2.diff ___ Python tracker ___ ___ Python-bugs-list mail

[issue1696199] Add collections.counts()

2009-01-09 Thread Raymond Hettinger
Changes by Raymond Hettinger : Added file: http://bugs.python.org/file12665/counter3.diff ___ Python tracker ___ ___ Python-bugs-list mailin

[issue1696199] Add collections.counts()

2009-01-09 Thread Raymond Hettinger
Changes by Raymond Hettinger : Removed file: http://bugs.python.org/file12662/counter.diff ___ Python tracker ___ ___ Python-bugs-list maili

[issue1696199] Add collections.counts()

2009-01-09 Thread Raymond Hettinger
Raymond Hettinger added the comment: Added a few more in-module tests. Added file: http://bugs.python.org/file12664/counter2.diff ___ Python tracker ___ __

[issue1696199] Add collections.counts()

2009-01-09 Thread Raymond Hettinger
Raymond Hettinger added the comment: Attaching an updated patch for Py2.7. * Kept OP's simple constructor call but renamed it from counts() to Counter(): item_counts = Counter('acabbacba') * Followed Guido's advice and avoided subclassing from defaultdict(). Instead, subclassed from dict,