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 slwebber
Recipients mark.dickinson, meador.inge, rhettinger, slwebber
Date 2012-08-08.06:18:18
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1344406700.55.0.721558952141.issue14182@psf.upfronthosting.co.za>
In-reply-to
Content
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?
History
Date User Action Args
2012-08-08 06:18:20slwebbersetrecipients: + slwebber, rhettinger, mark.dickinson, meador.inge
2012-08-08 06:18:20slwebbersetmessageid: <1344406700.55.0.721558952141.issue14182@psf.upfronthosting.co.za>
2012-08-08 06:18:19slwebberlinkissue14182 messages
2012-08-08 06:18:18slwebbercreate