Excerpts from Thomas L. Shinnick's message of Sun Jun 26 14:53:21 -0400 2011:
> See reference manual section 7.6  "Function definitions" under the 
> discussion subtitle "Default parameter values are evaluated when the 
> function definition is executed. "
>          
> http://docs.python.org/reference/compound_stmts.html#function-definitions
> 
> Yes, this is discussed in many places and many times, but why isn't 
> it in the Python FAQ?  Amazing, yes?
> 

Well, to be fair, I don't think most people actually read the FAQ.
The FAQ does say:

"Default arguments can be used to determine values once, at compile
time instead of at run time. This can only be done for functions or
objects which will not be changed during program execution..."

And he did modify the list during program execution. However this
isn't exactly forthright if you aren't looking for it / know what
you're reading.  I don't think it should be spilled out in detail but
maybe a "there are some tricks involved with mutable default
arguments (for example a list).  Refer to the language reference
(LINK) for more details" would be useful.

But I'm not really certain that would make much of a difference.
I'll Cc this to d...@python.org.
-- 
Corey Richardson
  "Those who deny freedom to others, deserve it not for themselves"
     -- Abraham Lincoln

Attachment: signature.asc
Description: PGP signature

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to