I'm trying to understand this behavior:
>>> Counter({'a':0})
Counter({'a': 0})
>>> Counter({'a':0}) + Counter({'a':0})
Counter()
>>> len(Counter({'a':0}))
1
>>> len(Counter({'a':0}) + Counter({'a':0}))
0
This seems inconsistent to me -- thoughts?
I'm trying to understand this behavior:
>>> Counter({'a':0})
Counter({'a': 0})
>>> Counter({'a':0}) + Counter({'a':0})
Counter()
>>> len(Counter({'a':0}))
1
>>> len(Counter({'a':0}) + Counter({'a':0}))
0
This seems inconsistent to me -- thoughts?
No it is not inconsistent. While summing two Counter classes, negative and zero counts are ignored. Go through the Notes section in this for more details: https://docs.python.org/2/library/collections.html#collections.Counter