Pre-PEP: Dictionary accumulator methods
gsakkis at rutgers.edu
Sat Mar 19 19:18:32 CET 2005
"Aahz" <aahz at pythoncraft.com> wrote:
> In article <JbL_d.8237$qN3.2116 at trndny01>,
> Raymond Hettinger <python at rcn.com> wrote:
> >The proposed names could possibly be improved (perhaps tally() is more active
> >and clear than count()).
> +1 tally()
-1 for count(): Implies an accessor, not a mutator.
-1 for tally(): Unfriendly to non-native english speakers.
+0.5 for add, increment. If incrementing a negative is unacceptable, how about
+1 for accumulate. I don't think that separating the two cases -- adding to a scalar or appending to
a list -- is that essential; a self-respecting program should make this obvious by the name of the
parameter anyway ("dictionary.accumulate('hello', words)" vs "a.accumulate('hello', b)").
More information about the Python-list