my_list = [1, 2] def f(): print my_list yield 11 print my_list yield 22 print my_list my_list[:] = f() print "finally ", print my_list output:
[1, 2] [1, 2] [1, 2] finally [11, 22] what I expected was:
[1, 2] [11, 2] [11, 22] finally [11, 22] Someone once told me slice assignment was in place. Obviously not. Is there an elegant way to achieve it?