<!DOCTYPE qhelp PUBLIC"-//Semmle//qhelp//EN""qhelp.dtd"><qhelp><overview><p>Using a constant value as a test in a conditional statement renders the statement pointless as onlyone branch will be run regardless of any other factors.</p></overview><recommendation><p>If the conditional statement is required for debugging or similar then use a variable instead.Otherwise, remove the conditional statement and any associated dead code.</p></recommendation><example><p>In the first example the <code>if</code> statement will always be executed and therefore can be removed. Thecontents of the statement should be kept though.</p><p>In the second example the statement <code>l = 100</code> is never executed because <code>1 > 100</code> is always false.However, it is likely that the intention was <code>l > 100</code> (the number '1' being misread as the letter 'l')and that the test should be corrected, rather than deleted.</p><sample src="ConstantInConditional.py" /></example><references><li>Python: <a href="http://docs.python.org/reference/compound_stmts.html#the-if-statement">The If Statement</a>.</li><li>Python: <a href="http://docs.python.org/reference/compound_stmts.html#the-while-statement">The While Statement</a>.</li><li>Python: <a href="http://docs.python.org/reference/expressions.html#literals">Literals (constant values)</a>.</li></references></qhelp>
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。