mirror of
https://github.com/github/codeql.git
synced 2025-12-24 04:36:35 +01:00
34 lines
982 B
XML
34 lines
982 B
XML
<!DOCTYPE qhelp PUBLIC
|
|
"-//Semmle//qhelp//EN"
|
|
"qhelp.dtd">
|
|
<qhelp>
|
|
<overview>
|
|
<p>
|
|
The dictionary returned by <code>locals()</code> is not a view of the function's locals, but a copy.
|
|
Therefore, modification of the dictionary returned from <code>locals()</code> will not modify the local
|
|
variables of the function.
|
|
</p>
|
|
|
|
|
|
</overview>
|
|
<recommendation>
|
|
|
|
<p>If the intention is to modify a local variable, then do so directly.
|
|
</p>
|
|
|
|
</recommendation>
|
|
<example>
|
|
<p>In this example, rather than assigning to the variable <code>z</code> directly, the dictionary returned by <code>locals()</code>
|
|
is modified.
|
|
|
|
</p><sample src="ModificationOfLocals.py" />
|
|
|
|
</example>
|
|
<references>
|
|
|
|
<li>Python Language Reference: <a href="http://docs.python.org/2/reference/compound_stmts.html#the-for-statement">The for statement</a>.</li>
|
|
<li>Python Tutorial: <a href="http://docs.python.org/2/tutorial/controlflow.html#for-statements">for statements</a>.</li>
|
|
|
|
</references>
|
|
</qhelp>
|