Tim Roberts wrote:
Mike Kent wrote:
On Feb 2, 6:40 pm, Baris Demir 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 paramet
Mike Kent wrote:
>
>On Feb 2, 6:40 pm, Baris Demir 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
On Mon, 02 Feb 2009 16:37:07 -0800, Mike Kent wrote:
> On Feb 2, 6:40 pm, Baris Demir 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 th
On Feb 2, 6:40 pm, Baris Demir 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/fa
> If you want a copy when you have
> to do so explicitly with "temp=d.copy()".
Or that! I forgot about that method. :)
Curiously, in 160k lines of code, I haven't explicitly copied a dictionary
once. I find that odd.
--S
--
http://mail.python.org/mailman/listinfo/python-list
On Mon, Feb 2, 2009 at 3:40 PM, Baris Demir wrote:
> Hi everybody,
>
> I am quite new to python and using it for my thesis. Luckily I found out
> some kind of behavior surprising to me and so unwanted in my code. I could
> not find any explanation, so solution for the code.
> It is simply like t
Baris Demir wrote:
> Hi everybody,
>
> I am quite new to python and using it for my thesis. Luckily I found
> out some kind of behavior surprising to me and so unwanted in my code. I
> could not find any explanation, so solution for the code.
> It is simply like this:
>
> /*li = another_module.gl