On 23.06.2017 03:02, Cameron Simpson wrote:
How about something like this?
try:
val = bah[5]
except IndexError:
# handle your expected exception here
else:
foo(val)
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. :-(
Regards,
Sven
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/