are you really meant to use exceptions for program flow? I really like Python except that it seems to encourage constructs like
Code:
try:
v = dic[keyVal]
except(KeyError):
v = -1
I know there's a .get() function for this specific situation, but I mean in general, is this encouraged, in a situation where an exception is quite likely to be thrown? e.g. Dive Into Python suggests using exceptions for figuring out if a given external module is available. Is this really OK? Is it "unpythonic" to say stuff like "you shouldn't use exceptions here because the compiler optimizes for the situation where no exception is thrown"? Or "you shouldn't use exceptions here because when I read your code, I expect that an exception only occurs in an unusual situation"? Or "exceptions are basically syntactic sugar for GOTO, which is ugly, so you shouldn't use them if at all possible"?
I don't think I would even ask this question if I was sober, but even tomorrow morning I will be interested in your feedback.