>
> https://docs.python.org/3.8/library/collections.html has some
> examples using collections.Counter, which is clearly described
> as being a subclass of dict.  Amongst the examples:
>
>      c + d  # add two counters together:  c[x] + d[x]
>
> That's the + operator operating on two dicts (don't make me
> quote the Liskov Substitution Principle), but doing something
> really different than the base operator.
>
> So if I know that c and d (or worse, that one of them) is a
> dict, then interpreting c + d becomes much more interesting,


Killing a use of a common operator with a very common built in data type
because the operator is used in a different way by a specialized object in
the stdlib seems a bit backwards to me.

Frankly, I think considering Counter as a dict subclass is the mistake
here, even if it is true.

-CHB
-- 
Christopher Barker, PhD

Python Language Consulting
  - Teaching
  - Scientific Software Development
  - Desktop GUI and Web Development
  - wxPython, numpy, scipy, Cython
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to