Fra*_*ter 28 python pep8 pylint
如果我使用pylint(通过sublimerlinter),我收到以下警告消息:
W602 deprecated form of raising exception
这个我如何在我的代码中使用异常:
if CONDITION == True:
raise ValueError, HELPING_EXPLANATION
Run Code Online (Sandbox Code Playgroud)
Fra*_*ter 30
像这样提出你的异常:
if CONDITION == True:
raise ValueError(HELPING_EXPLANATION)
Run Code Online (Sandbox Code Playgroud)
引发异常时,请使用raise
ValueError('message')
而不是旧形式raise ValueError, 'message'
.使用paren-using表单是首选,因为当异常参数很长或包含字符串格式时,由于包含括号,您不需要使用行继续符.旧的表单将在Python 3中删除.
归档时间: |
|
查看次数: |
6411 次 |
最近记录: |