I'm just reading PEP 3107 (function annotations) and wonder why exceptions are not mentioned there. I think it would be helpful if one could specify which exceptions can be raised by a function, similarly to how it is possible in C++ using the "throw" clause. The syntax would be something like this:
def foo(a: expr, b: expr = 5) raises expr -> expr:
The expr in that "raises" clause should be a list of Exceptions.

Having the list of possible exceptions as annotation alone would be already helpful. Of course it could be also discussed whether Python should check that the function really raises only these exceptions (as in C++), or we could even have checked exceptions (as in Java, but this seems to be a controversial issue).
Has this already been discussed, or is it in a different PEP?

-- Christoph
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to