December 2000
Intermediate to advanced
816 pages
16h 57m
English
The interpreter was responsible for raising all of the exceptions which we have seen so far. These exist as a result of encountering an error during execution. A programmer writing an API may also wish to throw an exception on erroneous input, for example, so Python provides a mechanism for the programmer to explicitly generate an exception: the raise statement.
The raise statement is quite flexible with the arguments which it supports, translating to a large number of different formats supported syntactically. The general syntax for raise is:
raise [Exception [, args [, traceback]]]
The first argument, Exception, is the name of the exception to raise. If present, it must either be a string, ...
Read now
Unlock full access