我想了解关于不带参数引发异常的最佳实践。 在官方Python文档中,你可以看到这个:
try:
raise KeyboardInterrupt
(http://docs.python.org/tutorial/errors.html 第8.6章)
在一些不同的代码中,比如Django或Google code中,你能看到这个:
def AuthenticateAndRun(self, username, password, args):
raise NotImplementedError()
(http://code.google.com/p/neatx/source/browse/trunk/neatx/lib/auth.py)
在没有参数的情况下,异常在被引发之前就已经实例化了。实例化一个没有参数的异常的目的是什么?我应该使用第一种情况还是第二种情况?
提前感谢 法比安