function scope

Baris Demir demirbaris at gmail.com
Tue Feb 3 19:57:37 EST 2009


Tim Roberts wrote:
> Mike Kent <mrmakent at cox.net> wrote:
>   
>> 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
>>     
>
> Actually, he hasn't.  His problem is more fundamental.
>
> However, this is still a good thing for you to point out now and then.
>   

Thanks a lot for the replies guys. They all helped a lot. And, I guess, 
I should read a lot more about python, it is not as simple as it seems 
at the beginning, or for the beginners:)
cheers
BD




More information about the Python-list mailing list