a...@pythoncraft.com (Aahz) writes:
> Standard Python idiom:
> 
> try:
>     d[key] += value
> except KeyError:
>     d[key] = value
> 
> Maybe you need to re-think "appropriate".

But more recent style prefers:

   d = collections.defaultdict(int)
   ...
   d[key] += value
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to