On 23.06.2017 03:02, Cameron Simpson
How about something like this?
val = bah
# handle your expected exception here
That is the kind of refactor to which I alluded in the paragraph
above. Doing that a lot tends to obscure the core logic of the
code, hence the desire for something more succinct requiring less
internal code fiddling.
And depending on how complex bha.__getitem__ is, it can raise
IndexError unintentionally as well. So, rewriting the outer code
doesn't even help then. :-(