|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here! |
|
#1
|
|||
|
|||
|
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
|
||||
|
||||
|
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. |
|
#3
|
|||
|
|||
|
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 |
|
#4
|
|||
|
|||
|
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/ |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Python Programming > multi arrays in python |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|