Updates counter with the tallies from the given iterable, dictionary or Counter.
(self, iterable=None, **kwargs)
| 26 | return 0 |
| 27 | |
| 28 | def update(self, iterable=None, **kwargs): |
| 29 | """ Updates counter with the tallies from the given iterable, dictionary or Counter. |
| 30 | """ |
| 31 | if kwargs: |
| 32 | self.update(kwargs) |
| 33 | if hasattr(iterable, "items"): |
| 34 | for k, v in iterable.items(): |
| 35 | self[k] = self.get(k, 0) + v |
| 36 | elif hasattr(iterable, "__getitem__") \ |
| 37 | or hasattr(iterable, "__iter__"): |
| 38 | for k in iterable: |
| 39 | self[k] = self.get(k, 0) + 1 |
| 40 | |
| 41 | def most_common(self, n=None): |
| 42 | """ Returns a list of the n most common (element, count)-tuples. |