Pre-PEP: Dictionary accumulator methods

El Pitonero pitonero at gmail.com
Sat Mar 19 13:56:14 EST 2005


George Sakkis wrote:
> "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
> update/updateby/updateBy ?
> +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)").

What about no name at all for the scalar case:

a['hello'] += 1
a['bye'] -= 2

and append() (or augmented assignment) for the list case:

a['hello'].append(word)
a['bye'] += [word]

?




More information about the Python-list mailing list