[Python-ideas] Type hints for functions with side-effects and for functions raising exceptions
Christopher Barker
pythonchb at gmail.com
Thu Feb 21 03:09:54 EST 2019
On Wed, Feb 20, 2019 at 11:52 PM Ben Rudiak-Gould <benrudiak at gmail.com>
wrote:
> Other functions also conceptually have three ways of returning:
> ordinary return with a value, a documented special return like
> KeyError, and pass-through exceptions.
well, I wouldn't call that three ways of returning...
But yes, there is no (easy) way to distinguish an Exception raised by the
function you called, and one raised somewhere deeper that.
And I have been bitten by that more than once. It makes "Easier to ask
forgiveness than permission" kind of tricky.
But I've found that good unit tests help a lot.
And Exception handling is messy -- the point made by the OP, I'm not sure
there's a better way to do it.
-CHB
--
Christopher Barker, PhD
Python Language Consulting
- Teaching
- Scientific Software Development
- Desktop GUI and Web Development
- wxPython, numpy, scipy, Cython
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20190221/d69bae88/attachment.html>
More information about the Python-ideas
mailing list