
On 10/21/19 9:51 AM, Steven D'Aprano wrote:
Dicts are a key:value store, not a multiset, and outside of specialised subclasses like Counter, we can't expect that adding the values is meaningful or even possible. "Adding the values" is too specialised and not general enough for dicts ...
Iterables are ordered collections of values, and outside of specialized subclasses, we can't expect that adding the values is meaningful or even possible. "Adding the values" is too specialized and not general enough for iterables. And yet the builtin function sum exists and works the way it does. Lately, I tend to reduce or fold my collections rather than to use symbolic operators, and to write specialized functions when it comes to use cases like preferences. I'd *almost* vote for | operating on the keys (because keys are like a set) and + for operating on values (because adding one key to another is more meaningless than adding arbitrary values), but that doesn't seem quite right, either.