Pre-PEP: Dictionary accumulator methods
Ivan Van Laningham
ivanlan at pauahtun.org
Fri Mar 18 20:34:41 EST 2005
Hi All--
Maybe I'm not getting it, but I'd think a better name for count would be
add. As in
d.add(key)
d.add(key,-1)
d.add(key,399)
etc.
Raymond Hettinger wrote:
>
> I would like to get everyone's thoughts on two new dictionary methods:
>
> def count(self, value, qty=1):
> try:
> self[key] += qty
> except KeyError:
> self[key] = qty
>
There is no existing add() method for dictionaries. Given the name
change, I'd like to see it.
Metta,
Ivan
----------------------------------------------
Ivan Van Laningham
God N Locomotive Works
http://www.pauahtun.org/
http://www.andi-holmes.com/
Army Signal Corps: Cu Chi, Class of '70
Author: Teach Yourself Python in 24 Hours
More information about the Python-list
mailing list