[issue18127] Strange behaviour with default list argument

2013-06-03 Thread Barry A. Warsaw
Barry A. Warsaw added the comment: While it's true that it can be confusing to users, it's not a bug. http://docs.python.org/2/reference/compound_stmts.html#function and a nice treatise on the subject by the Effbot: http://effbot.org/zone/default-values.htm -- nosy: +barry __

[issue18127] Strange behaviour with default list argument

2013-06-03 Thread Eric V. Smith
Eric V. Smith added the comment: It's by design. Search for "mutable default arguments", for example http://docs.python-guide.org/en/latest/writing/gotchas.html#mutable-default-arguments -- nosy: +eric.smith resolution: -> invalid stage: -> committed/rejected status: open -> closed _

[issue18127] Strange behaviour with default list argument

2013-06-03 Thread Poul-Henning Kamp
New submission from Poul-Henning Kamp: I'd like to nominate this piece of code as candidate for the next round of "Most unexpected python behaviour" awards: def foo(a, x = []): x.append(a) return x print(foo(1)) print(foo(2)) I expected the output to be: [1]