This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ethan.furman
Recipients Joshua.Chin, ethan.furman, r.david.murray, rhettinger
Date 2014-10-30.18:00:49
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1414692049.49.0.718328518303.issue22766@psf.upfronthosting.co.za>
In-reply-to
Content
Indeed -- we mostly discuss with each other to try and sway his opinion.  :)

stdlib types should not let every error bubble up.  Consider a dict:
----------------------------------------------------------------
--> d = {}
--> d += 2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for +=: 'dict' and 'int'
----------------------------------------------------------------

now look at Counter
----------------------------------------------------------------
--> from collections import Counter
--> c = Counter()
--> c += 2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/ethan/source/python/cpython/Lib/collections/__init__.py", line 709, in __iadd__
    for elem, count in other.items():
AttributeError: 'int' object has no attribute 'items'
----------------------------------------------------------------

Counter is not user-friendly in this case.

There are other areas of Counter that accept arbitrary mappings, so I would be fine the __ixxx__ methods also accepting arbitrary mappings, but if the thing passed in *will not* work with Counter, then returning NotImplemented is the appropriate course of action.
History
Date User Action Args
2014-10-30 18:00:49ethan.furmansetrecipients: + ethan.furman, rhettinger, r.david.murray, Joshua.Chin
2014-10-30 18:00:49ethan.furmansetmessageid: <1414692049.49.0.718328518303.issue22766@psf.upfronthosting.co.za>
2014-10-30 18:00:49ethan.furmanlinkissue22766 messages
2014-10-30 18:00:49ethan.furmancreate