#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Location
    Warsaw , Poland
    Posts
    1
    Rep Power
    0

    multi arrays in python


    hi,
    i need to create a multi array (matrix) and i have no idea how to do it :/ i have a variable named x and i want to create on this variable an array with double index (10x10) of integer.
    any1 can halp me? it is possible in python?
  2. #2
  3. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    Your gonna have to give me a little more info about what your trying to do, if you mean an array within an array then..

    Code:
    array = [[1, 2],[3, 4],[5, 6],[7, 8],[9, 10],[11, 12],[13, 14]]
    you can stick as many arrays of any value inside other array as you like. and access them in the same way i.e to get the value 1 you would use array[0][1] and so on.

    Oh, future ref' an array in Python is called a list

    Hope this helps,
    Mark.
  4. #3
  5. No Profile Picture
    Tattooed Python-Lovin' Freak-Boy
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2001
    Location
    orange county, CA
    Posts
    16
    Rep Power
    0
    actually, there is an array module in python's standard library, but it only holds one datatype (like arrays in java/c/c++)

    but, multidimentional lists aren't builtin to python, but they can be created/indexed easily enough
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Posts
    6
    Rep Power
    0
    You probably want to use the the Numeric module which has an array type built in just for creating and manipulating matrices.

    Actually this is the link to numarray which is the newer module which is going to be phasing out Numeric.

    It's much faster than using lists to represent matrices and much more memory efficient, lists are memory hogs. Also it has tons of built in functions to help you manipulate matrices.

    Hope this helps.


    http://pfdubois.com/numpy/

IMN logo majestic logo threadwatch logo seochat tools logo