Skip to content

Commit 556fa42

Browse files
[3.14] gh-154746: Update docstring for collections.Counter (GH-154792) (GH-154794)
Added a note to `collections.Counter`'s docstring that initializing a `Counter` from a `Mapping` or `Counter` will have different behaviour than initializing from other `Iterable`s. This behaviour was already documented in the canonical docs but is missing from the help() output. (cherry picked from commit 22a123f) Co-authored-by: Dan Shernicoff <dan@brassnet.biz>
1 parent 722bcec commit 556fa42

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

Lib/collections/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,9 @@ class Counter(dict):
553553
or multiset. Elements are stored as dictionary keys and their counts
554554
are stored as dictionary values.
555555
556+
When constructed from a Mapping or Counter, the original object's
557+
values will be used as the initial counts.
558+
556559
>>> c = Counter('abcdeabcdabcaba') # count elements from a string
557560
558561
>>> c.most_common(3) # three most common elements

0 commit comments

Comments
 (0)