Stephen Webber added the comment:
Hmm, that is odd behavior indeed.
I think having keys that point to zero values is important for iterating over a
set. For example:
x = Counter(a=10, b=0)
for k in set(x):
... x[k] += 1
...
x
Counter({'a': 11, 'b': 1})
is probably preferable to
x = Counter(a=10, b=0)
for k in set(x):
... x[k] += 1
...
x
Counter({'a': 11})
Perhaps to ensure intuitive behavior we could ensure that
Counter(a = 3) + Counter(b = 0) == Counter(a = 3, b = 0)
True
by aggregating all keys into the new Counter object, even those with zero
values? I would be happy to make such a patch, as it would be good experience
for me to learn. Would this be an acceptable solution, and is there other odd
behavior at work here?
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14182
___
___
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com