initialized list: strange behavior

2008-11-24 Thread alexander . genkin
Hi Python experts! Please explain this behavior: >>> nn=3*[[]] >>> nn [[], [], []] >>> mm=[[],[],[]] >>> mm [[], [], []] Up till now, 'mm' and 'nn' look the same, right? Nope! >>> mm[1].append(17) >>> mm [[], [17], []] >>> nn[1].append(17) >>> nn [[17], [17], [17]] ??? Python 2.5 Win XP Thank

Re: initialized list: strange behavior

2008-11-25 Thread alexander . genkin
The issue is exhausted in Python Library Reference, Chapter 3.6, so I should apologize for initial posting. All comments were helpful, though Arnaud and Steve are right that pass-by-anything is off the point. Thanks All! -- http://mail.python.org/mailman/listinfo/python-list