2011年5月11日 星期三

[Python] raise Handling Exceptions

 


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


>>> raise NameError('HiThere')
Traceback (most recent call last):
File "<stdin>", line 1, in ?
NameError: HiThere

 


The sole argument to raise indicates the exception to be raised. This must be either an exception instance or an exception class (a class that derives from Exception).

8. Errors and Exceptions — Python v2.7.1 documentation
http://docs.python.org/tutorial/errors.html#raising-exceptions


沒有留言:

張貼留言