Skip to content

Commit e667f26

Browse files
[3.13] gh-154746: Update docstring for collections.Counter (GH-154792) (GH-154795)
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 31b4886 commit e667f26

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
@@ -550,6 +550,9 @@ class Counter(dict):
550550
or multiset. Elements are stored as dictionary keys and their counts
551551
are stored as dictionary values.
552552
553+
When constructed from a Mapping or Counter, the original object's
554+
values will be used as the initial counts.
555+
553556
>>> c = Counter('abcdeabcdabcaba') # count elements from a string
554557
555558
>>> c.most_common(3) # three most common elements

0 commit comments

Comments
 (0)