python memorize default parameter value or not
<p>From this blog, it seems Python memorize default parameter value during each function call.</p>

<p><a href="http://effbot.org/zone/default-values.htm" rel="nofollow">http://effbot.org/zone/default-values.htm</a></p>

<p>But I tested and it seems not? For example, the 2nd function call does not print value of x, y is still False other than memorized value?</p>

<pre><code>def foo(x, y=False):
    if y:
        print x

if __name__ == "__main__":
    foo(100, True) # print
    foo(300) # not print
</code></pre>

<p>regards,
Lin</p>

<p>The default object for a parameter is determined once and only once, when the function is defined.  (I am ignoring the possibility of diffing into the function object from outside and somehow changing the default object.)  If the default object is not mutable, as is true of False, end of story.</p>

<p>If the default object <em>is</em> mutable, then its contents can be changed without changing the identity of the object.  If the Lundh reference, the default object is a list and a list <em>can</em> be mutated.  Each call sees the list in its current state.</p>

python python-2.7