A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2007-April/072513.html below:

[Python-Dev] function for counting items in a sequence

[Python-Dev] function for counting items in a sequence [Python-Dev] function for counting items in a sequenceRaymond Hettinger python at rcn.com
Sun Apr 8 09:56:07 CEST 2007
Instead of a separate function in collections, it may be sensible to stick with
the familiar and provide a dictionary contructor for the commonly encounter use
case of counting things:

@classmethod
def fromcount(cls, iterable):
    d = cls()
    for elem in iterable:
        d[elem] = d.get(elem, 0) + 1
    return d



Raymond
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4