On Oct 11, 9:30 pm, [EMAIL PROTECTED] wrote:
>     Jill> How do I define a 2d list?
>
> Python doesn't truly have 2d lists in the way you might think of 2d arrays
> in C or Fortran.  It has 1d lists which can contain any Python object,
> including other lists.  If you wanted to create a 4x5 list you'd do
> something like this:
>
>     N = 4
>     M = 5
>     mylist = []
>     for i in range(N):
>         mylist.append([0.0] * M)
>
> If you are looking to do numeric work with such multidimensional lists you
> should consider the builtin array object or the numpy package:
>
>    http://docs.python.org/dev/library/array.html#module-array
>    http://numpy.scipy.org/
>
> Skip

I think you can do

mylist = [[]] or somesuch...

if you are looking on google for examples you will comonly find them
in spreadsheets..  I have one in the editor part of dex tracker
(available on source forge)  The array will start at zero and ie x[0]
and will keep growing as long as you .append it..  You don't define
the size in advance like you would with other languages..  You need to
have values befour you try to
use a location in the array.
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to