Hendrik van Rooyen <hend...@microcorp.co.za> writes:
> Standard Python idiom:
> 
> if key in d:
>   d[key] += value
> else:
>   d[key] = value

The issue is that uses two lookups.  If that's ok, the more usual idiom is:

  d[key] = value + d.get(key, 0)
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to