[Edu-sig] Using try / except: any stipulations against routine use?
Corey Richardson
kb1pkl at aim.com
Tue Dec 13 22:39:25 CET 2011
On 12/13/2011 04:30 PM, Kirby Urner wrote:
> I think of a "key not found" event
> in a dict as "routine, to be expected" whereas I think of
> try: / except: as for "crying wolf" (not for everyday
> contingencies). The opposite bias is: why make that
> distinction, try: / except: is a perfectly reasonable
> construct for trapping a new key to a dict.
>
More evidence for the "perfectly reasonable": Iterators are implemented
with the StopIteration exception. You can find a few other examples in
the language for things like that. I think it's perfectly reasonable myself.
--
Corey Richardson
More information about the Edu-sig
mailing list