Multidimensional arrays - howto?

D

doodle4

Hello all,

I am trying to convert some C code into python. Since i am new to
python, i would like to know how to deal with multidimensional arrays?

Thanks,
-Joe

Here's a snippet of what i am trying to convert:

# define table0 15
# define table1 20

unsigned int Table[table0][table1]

if(Table[table0][table1] != 0)
{
Table[table0][table1]--
}
 
D

Daniel Yoo

(e-mail address removed) wrote:
: Hello all,

: I am trying to convert some C code into python. Since i am new to
: python, i would like to know how to deal with multidimensional arrays?


Here you go:


http://python.org/doc/faq/programming.html#how-do-i-create-a-multidimensional-list


Also, if your table is relatively sparse, you might even be able to
use a dictionary, because a 2-d array can be considered as a mapping
between (index1, index2) keys and its values.
 
C

Colin J. Williams

Hello all,

I am trying to convert some C code into python. Since i am new to
python, i would like to know how to deal with multidimensional arrays?

Thanks,
-Joe

Here's a snippet of what i am trying to convert:

# define table0 15
# define table1 20

unsigned int Table[table0][table1]

if(Table[table0][table1] != 0)
{
Table[table0][table1]--
}
You might consider numarray. This is a package which is downloadable
from Source Forge and intended for numeric and other arrays.

Colin W.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top