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/072525.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 sequenceGeorg Brandl g.brandl at gmx.net
Sun Apr 8 20:23:15 CEST 2007
Steven Bethard schrieb:
> A summary response to the issues raised so far...
> 
> On what the name should be:
> * Adam Olsen - countunique(), countdistinct(), countduplicates()
> * Greg Ewing - counteach(), countall()
> * Kevin Jacobs - tally()
> * Guido - counts() is fine
> So I guess I'll stick with counts().

I can live with counts(), though I always ask myself "who counts?" ;)

> On whether the count of a missing item should be 0 or a KeyError:
> * Brett Cannon - 0
> * Greg Ewing - 0
> Because the number of times an unseen item was seen is 0. So I'll
> stick with returning 0. That's the normal behavior for a
> defaultdict(int).

+1 from me too for 0.

> Raymond Hettinger suggested that the function should be called
> dict.fromcount() instead. I lean towards the collections module
> instead of a dict classmethod because the feedback above suggests that
> the count of an unseen item should be 0. This means returning a
> defaultdict(int), which might be a bit confusing from a classmethod of
> *dict*.

defaultdict.fromcount? Too obscure, I guess.

Georg

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