On 21 Set, 15:07, George Sakkis <[EMAIL PROTECTED]> wrote: > On Sep 21, 8:51 am, Alex <[EMAIL PROTECTED]> wrote: > > > > > Hi all! > > > I have a problem understanding the behaviour of this snippet: > > > data_set = ({"param":"a"},{"param":"b"},{"param":"c"}) > > > for i in range(len(data_set)): > > ds = data_set[:] > > data = ds[i] > > if i == 1: data['param'] = "y" > > if i == 2: data['param'] = "x" > > > print data_set > > > This script print out: > > ({'param': 'a'}, {'param': 'y'}, {'param': 'x'}) > > > Why? I'm coping data_set in ds so why data_set is changed? > > Because you're doing a shallow > copy:http://docs.python.org/lib/module-copy.html > > George
Thanks a lot. It was giving me and headache! -- http://mail.python.org/mailman/listinfo/python-list