Adam DePrince wrote: > Now, as for your example m * [ n * [0]], I would exclude it from a best > practices document. If your goal is to create a two dimensional array > of numbers, it doesn't work. The first part, n* [0] is right, you are > creating a list of n zeros, and when you say l[x]=y you are replacing > that element. > > The second part, m *, is wrong. You are creating a list of m references > to the same list of n zeros.
I know its wrong. It was a mistake I made several times when I was earning Python. The m * [ n * [0]] problem is a dark corner of Python that exists because Python variables are really pointers. Unfortunately, this dark corner is visible to newbies. Which is why it needs to be mentioned. _______________________________________________ Python-3000 mailing list [email protected] http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com
