Message167668
| 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:20 | slwebber | set | recipients:
+ slwebber, rhettinger, mark.dickinson, meador.inge |
| 2012年08月08日 06:18:20 | slwebber | set | messageid: <1344406700.55.0.721558952141.issue14182@psf.upfronthosting.co.za> |
| 2012年08月08日 06:18:19 | slwebber | link | issue14182 messages |
| 2012年08月08日 06:18:18 | slwebber | create |
|