[Python-ideas] fixing mutable default argument values
jjb5 at cornell.edu
Thu Jan 18 14:44:12 CET 2007
Calvin Spealman wrote:
> I dont understand how that would be different than doing
> c = c if c is not None else Bar([2,3,4])
Because that would be calling Bar(), perhaps creating a new Bar object,
every time foo() is called with None for c, which is not what a default
argument values are about. I'm proposing a way to create function local
singleton objects, removing them from the parameter list.
local history = 
def foo(x, history=):
and then hoping that nobody calls foo() with a history parameter.
More information about the Python-ideas