Paul Rubin wrote:
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
Yes, the motivation was to reduce 4 lines to 1 line for a common use case, and not because of any sense of 'inappropriateness'.
tjr -- http://mail.python.org/mailman/listinfo/python-list