Pre-PEP: Dictionary accumulator methods
Aahz
aahz at pythoncraft.com
Fri Mar 18 21:04:19 EST 2005
In article <JbL_d.8237$qN3.2116 at trndny01>,
Raymond Hettinger <python at rcn.com> 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
You mean
def count(self, key, qty=1)
Right?
--
Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/
"The joy of coding Python should be in seeing short, concise, readable
classes that express a lot of action in a small amount of clear code --
not in reams of trivial code that bores the reader to death." --GvR
More information about the Python-list
mailing list