[New-bugs-announce] [issue18127] Strange behaviour with default list argument

Poul-Henning Kamp report at bugs.python.org
Mon Jun 3 21:38:11 CEST 2013

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 = []):
        return x


I expected the output to be:
but I get:
    [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 <report at bugs.python.org>

More information about the New-bugs-announce mailing list