Issue 1661603: Misleading behavior for [] and {} default arguments (original) (raw)

Hello

On python 2.3.4 and 2.4.3,

def a(x=[]): ... return x ... y=a() y.append(1) a() [1]

Hence, the default argument is not recomputed. The same behavior occurs with x={} instead of x=[].

This looks like a bug because it is not coherent with

def f(): ... return [] ... y=f() y.append(5) f() []

So, is it a feature?

Thanks