When raising an exception, use raise ValueError('message') instead of the older form raise ValueError, 'message'.
The paren-using form is preferred because when the exception arguments are long or include string formatting, you don't need to use line continuation characters thanks to the containing parentheses. The older form will be removed in Python 3.
提出这样的例外:
来自PEP 8 -- Style Guide for Python Code - Programming Recommendations:
相关问题 更多 >
编程相关推荐