Multidimensional arrays - howto?

Discussion in 'Python' started by doodle4@gmail.com, Feb 14, 2005.

  1. Guest

    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]--
    }
     
    , Feb 14, 2005
    #1
    1. Advertising

  2. Daniel Yoo Guest

    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.
     
    Daniel Yoo, Feb 14, 2005
    #2
    1. Advertising

  3. Fredrik Lundh, Feb 14, 2005
    #3
  4. 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?
    >
    > 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.
     
    Colin J. Williams, Feb 16, 2005
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. d[ - - ]b

    Multidimensional arrays? anything else?

    d[ - - ]b, May 18, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    1,684
    AlexS
    May 18, 2004
  2. Jay
    Replies:
    1
    Views:
    2,628
    BarryNL
    Jan 30, 2004
  3. geclinke
    Replies:
    1
    Views:
    5,135
    jackie
    Jun 18, 2004
  4. Philipp
    Replies:
    21
    Views:
    1,189
    Philipp
    Jan 20, 2009
  5. Francesco
    Replies:
    2
    Views:
    1,171
    Francesco
    Nov 6, 2009
Loading...

Share This Page