<div dir="ltr"><div dir="ltr">On Wed, Feb 20, 2019 at 11:52 PM Ben Rudiak-Gould <<a href="mailto:benrudiak@gmail.com">benrudiak@gmail.com</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Other functions also conceptually have three ways of returning:<br>
ordinary return with a value, a documented special return like<br>
KeyError, and pass-through exceptions.</blockquote><div><br></div><div>well, I wouldn't call that three ways of returning...</div><div><br></div><div>But yes, there is no (easy) way to distinguish an Exception raised by the function you called, and one raised somewhere deeper that.</div><div><br></div><div>And I have been bitten by that more than once. It makes "Easier to ask forgiveness than permission" kind of tricky.</div><div><br></div><div>But I've found that good unit tests help a lot.</div><div><br></div><div>And Exception handling is messy -- the point made by the OP, I'm not sure there's a better way to do it.</div><div><br></div><div>-CHB</div><div><br></div></div>-- <br><div dir="ltr" class="gmail_signature">Christopher Barker, PhD<br><br> Python Language Consulting<br> - Teaching<br> - Scientific Software Development<br> - Desktop GUI and Web Development<br> - wxPython, numpy, scipy, Cython<br></div></div>