2d lists
beliavsky_at_aol.com
Date: 05/31/04
- Next message: Dave: "http file post"
- Previous message: David MacQuigg: "Re: Unification of Methods and Functions"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 30 May 2004 16:44:03 -0700
xiaohua_sun@yahoo.com (SunX) wrote in message news:<337e6cd5.0405291411.4376debc@posting.google.com>...
> What is the best way to assign a 2d lists? Something like;
>
> for i in range(10):
> for j in range(10):
> aList[i][j] = i*j
>
> Thank you in advance.
(When I replied with subject "Re: 2d lists" Google groups complained.)
If you will use the 2d lists for numerical calculations, I would
recommend the Numeric or Numarray modules, which provide
multdimensional arrays that are much faster than lists of lists. A
restriction of Numeric or Numarray arrays is that all the elements
must be of the same type (as in Fortran).
With Numeric you could write
from Numeric import zeros
n = 10
alist = zeros([n,n])
for i in range(n):
for j in range(n):
alist[i,j] = i*j
- Next message: Dave: "http file post"
- Previous message: David MacQuigg: "Re: Unification of Methods and Functions"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|