function scope

Mike Kent mrmakent at cox.net
Mon Feb 2 19:37:07 EST 2009


On Feb 2, 6:40 pm, Baris Demir <demirba... at gmail.com> wrote:

> def simpleCut(d=dict()):
>        temp=d
>        for i in temp.keys():
>            if    (temp[i] == .......) :
>               temp[i]=new_value
> return temp

You have been bitten by the shared default parameter noobie trap:
http://www.python.org/doc/faq/general/#why-are-default-values-shared-between-objects



More information about the Python-list mailing list