On Saturday, 17 October 2009 16:30:55 Aahz wrote: > In article <[email protected]>, > > Tim Rowe <[email protected]> wrote: > >The point is that an exception causes a change in program flow, so of > >course they're used for flow control. It's what they do. The question > >is in what cases it's appropriate to use them. > > Standard Python idiom: > > try: > d[key] += value > except KeyError: > d[key] = value > > Maybe you need to re-think "appropriate".
Standard Python idiom: if key in d: d[key] += value else: d[key] = value Maybe you need to re-think "appropriate". - Hendrik -- http://mail.python.org/mailman/listinfo/python-list
