Missing exceptions in PEP 3107
Christoph Zwerschke
cito at online.de
Sat Aug 9 12:08:12 EDT 2008
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
More information about the Python-list
mailing list