Python bug? Indexing to matrices

Ben Finney ben+python at benfinney.id.au
Tue Jul 12 01:59:59 EDT 2011


David <davidbtdt at gmail.com> writes:

> Should the following line work for defining a matrix with zeros?
>
> c= [[0]*col]*row

No. Python lists are not matrixes and are not arrays.

If you want good implementations of arrays and matrices, use NumPy
<URL:http://numpy.scipy.org/>.

-- 
 \      “Properly read, the Bible is the most potent force for atheism |
  `\                                    ever conceived.” —Isaac Asimov |
_o__)                                                                  |
Ben Finney



More information about the Python-list mailing list