f | from collections import Counter | f | from collections import Counter |
| | | |
| class DefCounter(Counter): | | class DefCounter(Counter): |
| | | |
n | def __init__(self, iterable=None, /, missing=-1, **kwds): | n | def __init__(self, iterable=None, missing=-1, **kwds): |
| self._missing = missing | | self.missing = missing |
| super().__init__(iterable, **kwds) | | super().__init__(iterable, **kwds) |
| | | |
| def __missing__(self, key): | | def __missing__(self, key): |
t | return self._missing | t | return self.missing |
| | | |
| def __abs__(self): | | def __abs__(self): |
| return sum((x for x in self.values() if x > 0)) | | return sum((x for x in self.values() if x > 0)) |