[Python-Dev] Real-world use of Counter

Raymond Hettinger raymond.hettinger at gmail.com
Wed Nov 5 19:56:12 CET 2014


> On Nov 5, 2014, at 8:33 AM, Ethan Furman <ethan at stoneleaf.us> wrote:
> 
> I'm looking for real-world uses of collections.Counter, specifically to see if anyone has been surprised by, or had to spend extra-time debugging, issues with the in-place operators.

Please stop using the mailing lists as way to make an end-run around discussions on the tracker.  http://bugs.python.org/issue22766 <http://bugs.python.org/issue22766>   

Also, as asked the question is a bit loaded.  Effectively, it asks "has anyone ever been surprised by an exception raised by a duck-typed function or method"?

The in-place operations on counters are duck-typed.  They are intended (by design) to work with ANY type that has an items() method.   The exception raised if doesn't have on is an AttributeError saying that the operand needs to have an items() method.

I do not want to change API for already deployed code just because you would rather see a TypeError instead.  Minor API changes (switching exception types) creates unnecessary consternation for users.

Please let this one die.  It seems to have become your pet project even after I've made a decision and explained my rationale.


Raymond
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20141105/0b6d5eae/attachment.html>


More information about the Python-Dev mailing list