Dennis Sweeney <sweeney.dennis...@gmail.com> added the comment:

This is consistent with the docstrings of the methods:

---------------------------------------------------------------------
>>> help(Counter.__iadd__)
Help on function __iadd__ in module collections:

__iadd__(self, other)
    Inplace add from another counter, keeping only positive counts.
    
    >>> c = Counter('abbb')
    >>> c += Counter('bcc')
    >>> c
    Counter({'b': 4, 'c': 2, 'a': 1})

>>> help(Counter.update)
Help on function update in module collections:

update(self, iterable=None, /, **kwds)
    Like dict.update() but add counts instead of replacing them.
    
    Source can be an iterable, a dictionary, or another Counter instance.
    
    >>> c = Counter('which')
    >>> c.update('witch')           # add elements from another iterable
    >>> d = Counter('watch')
    >>> c.update(d)                 # add elements from another counter
    >>> c['h']                      # four 'h' in which, witch, and watch
    4
---------------------------------------------------------------------


However, it seems Counter.__iadd__ is not mentioned at all at 
https://docs.python.org/3/library/collections.html#collections.Counter. I think 
there could be a doc update.

----------
nosy: +Dennis Sweeney

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue45936>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to