functions, list, default parameters

Steven D'Aprano steve at REMOVE-THIS-cybersource.com.au
Fri Oct 22 03:36:21 EDT 2010


On Thu, 21 Oct 2010 19:53:53 -0700, John Nagle wrote:

>> This is a common newbie stumbling-block: Don't use lists (or anything
>> mutable) as default argument values
> 
>      That really should be an error.

No it shouldn't. Punishing everybody for a newbie mistake that nobody 
makes twice would be the error.

Default mutable arguments have their place, and there is an easy work-
around for anyone who wants default arguments to be created on function 
invocation rather than function definition.



-- 
Steven



More information about the Python-list mailing list