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]
[2]
but I get:
[1]
[1, 2]
Bug? (If not, I'd *love* to read the rationale for this behaviour...)
----------
messages: 190557
nosy: bsdphk
priority: normal
severity: normal
status: open
title: Strange behaviour with default list argument
type: behavior
versions: Python 2.7, Python 3.2
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue18127>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com