next up previous contents
Next: 8.5 User-defined Exceptions Up: 8 Errors and Exceptions Previous: 8.3 Handling Exceptions

8.4 Raising Exceptions

The raise statement allows the programmer to force a specified exception to occur. For example:

>>> raise NameError, 'HiThere'
Traceback (innermost last):
  File "<stdin>", line 1
NameError: HiThere
>>>
The first argument to raise names the exception to be raised. The optional second argument specifies the exception's argument.



guido@cnri.reston.va.us