Aaron Meurer added the comment:
I can't believe this issue was closed. Why can't Counter.__lt__(self, other)
just be all(self[i] < other[i] for i in self)?
Just because Counter supports weird stuff shouldn't bill it out. To follow that
logic, we should also remove Counter.subtract
>>> Counter(a='b') - Counter(a='c')
Traceback (most recent call last):
File "<ipython-input-5-31b2df7f8ff1>", line 1, in <module>
Counter(a='b') - Counter(a='c')
File "/Users/aaronmeurer/anaconda/lib/python3.5/collections/__init__.py",
line 709, in __sub__
newcount = count - other[elem]
TypeError: unsupported operand type(s) for -: 'str' and 'str'
It's super annoying that Counter supports all the basic set operations *except*
subset. A reminder that this *does* work:
>>> Counter(a=2) | Counter(a=1)
Counter({'a': 2})
And also fails on weird values:
>>> Counter(a='b') | Counter(a='c')
Traceback (most recent call last):
File "<ipython-input-8-f9768ad92117>", line 1, in <module>
Counter(a='b') | Counter(a='c')
File "/Users/aaronmeurer/anaconda/lib/python3.5/collections/__init__.py",
line 730, in __or__
if newcount > 0:
TypeError: unorderable types: str() > int()
----------
nosy: +Aaron.Meurer
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue22515>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com