[Tutor] (no subject)

Pijus Virketis virketis@fas.harvard.edu
Tue, 27 Nov 2001 18:38:52 -0500


--=====================_11117444==_.ALT
Content-Type: text/plain; charset="us-ascii"

Hi,

I am not quite sure what you mean by "two-dimensional" list, so I'll just show
what I would think of as a 2D list myself. Consider this:

>>> L = [[1, 2, 3], [4, 5,6], [7, 8, 9]]

This list of three list could be seen as a rough replication of the matrix:

1 2 3
4 5 6
7 8 9

The list can be indexed somewhat like a matrix:

>>> print L[1][2]
2

We asked for the first row and second column, and got the right number. This
could do the job for you. However, this list-array is not quite as neat to
work
with as a Matlab matrix, for instance, partly because it was intended to be a
more general thing than that. For real mathematical array implemention, check
out the Numeric Python module http://numpy.sourceforge.net/. There is also an
array datatype available through the array.py module, but at first glance it
seems like a subset of the list datatype. NumPy is probably the way to go.

Cheers, 

Pijus
------------------------------------------------------------
PGP PUBLIC KEY: www.fas.harvard.edu/~virketis/links
My weblog: www.fas.harvard.edu/~virketis

--=====================_11117444==_.ALT
Content-Type: text/html; charset="us-ascii"

<html>
Hi,<br>
<br>
I am not quite sure what you mean by &quot;two-dimensional&quot; list, so
I'll just show what I would think of as a 2D list myself. Consider
this:<br>
<br>
&gt;&gt;&gt; L = [[1, 2, 3], [4, 5,6], [7, 8, 9]]<br>
<br>
This list of three list could be seen as a rough replication of the
matrix:<br>
<br>
1 2 3<br>
4 5 6<br>
7 8 9<br>
<br>
The list can be indexed somewhat like a matrix:<br>
<br>
&gt;&gt;&gt; print L[1][2]<br>
2<br>
<br>
We asked for the first row and second column, and got the right number.
This could do the job for you. However, this list-array is not quite as
neat to work with as a Matlab matrix, for instance, partly because it was
intended to be a more general thing than that. For real mathematical
array implemention, check out the Numeric Python module
<a href="http://numpy.sourceforge.net/" eudora="autourl"><font color="#0000FF"><u>http://numpy.sourceforge.net/</a></font></u><font color="#000000">.
There is also an array datatype available through the array.py module,
but at first glance it seems like a subset of the list datatype. NumPy is
probably the way to go.<br>
<br>
Cheers, <br>
<br>
Pijus</font><br>
<div>------------------------------------------------------------</div>
<div>PGP PUBLIC KEY:
<a href="http://www.fas.harvard.edu/~virketis/links" EUDORA=AUTOURL>www.fas.harvard.edu/~virketis/links</a></div>
<div>My weblog:
<a href="http://www.fas.harvard.edu/~virketis" EUDORA=AUTOURL>www.fas.harvard.edu/~virketis</a></div>
</html>

--=====================_11117444==_.ALT--