Martin v. Löwis <[EMAIL PROTECTED]> added the comment: This is not a bug. Please read about references in Python, and what this means:
py> b=[0] py> a=[b,b] py> a[0] is a[1] True py> c=[[0],[0]] py> c[0] is c[1] False py> c[0] == c[1] True In short, there is only a single list stored in the variable gridRow, and the very same list is appended multiple times (not copies of the list, but the very same object). There are then multiple ways to refer to the list, such as g[0] or g[1]. To avoid sharing the list objects, either create new lists (i.e. nest the first loop into the second one, and create a new gridRow on each outer loop iteration), or create clones of the first list, e.g. grid.append(list(gridRow)) # or grid.append(gridRow[:]) ---------- nosy: +loewis resolution: -> invalid status: open -> closed _______________________________________ Python tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue3072> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com