Local variables persist in functions?

Fredrik Lundh fredrik at pythonware.com
Fri Nov 24 12:11:01 CET 2006

<120psi at gmail.com> wrote:

> chunks = _chunkify( list, size )   # _curList keeps its previous value!
> chunks = _chunkify( list, size, list() )    # this works as expected
> Considering the default value of _curList, these statements should be
> identical.  Any pointers?


> Did I miss something in the python reference manual?  (running 2.4.3, fyi)

the paragraph that starts with "Default parameter values are evaluated when
the function definition is executed." in bold,  perhaps.  I've highlighted it
on this page:



More information about the Python-list mailing list