mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-16 22:51:17 +07:00
21 lines
613 B
HTML
21 lines
613 B
HTML
<html>
|
|
<body>
|
|
<p>Reports a problem when a mutable value as a list or dictionary is detected in a default value for
|
|
an argument. <br/>
|
|
Default argument values are evaluated only once at function definition time,
|
|
which means that modifying the
|
|
default value of the argument will affect all subsequent calls of that function.</p>
|
|
<p><b>Example:</b></p>
|
|
<pre><code>
|
|
def func(s, cache={}):
|
|
cache[s] = None
|
|
</code></pre>
|
|
<p>When the quick-fix is applied, the code changes to:</p>
|
|
<pre><code>
|
|
def func(s, cache=None):
|
|
if cache is None:
|
|
cache = {}
|
|
cache[s] = None
|
|
</code></pre>
|
|
</body>
|
|
</html> |