Don't Understand This Error

Bruno Desthuilliers bruno.42.desthuilliers at websiteburo.invalid
Wed Dec 2 11:55:01 CET 2009


> On Wed, Dec 2, 2009 at 2:33 AM, Victor Subervi <victorsubervi at gmail.com> wrote:
>>
>> def colors(callingTable, which='', specificTables=[]):

Warning : default arguments are eval'd only once, at function creation 
time. This is a well known gotcha that can lead to unexpected behaviours 
like:


def foo(x, bar=[])
    bar.append("gotcha %s" % x)
    print bar

for i in range(5):
    bar(i)





More information about the Python-list mailing list