Two dimensional lists

Laszlo Nagy gandalf at designaproduct.biz
Thu Jan 25 11:42:12 EST 2007


> # shouldn't I be able to fill the lists simply by pointing to a location?
>
> matrix[a_idx, p_idx] = 0x219 # and so on?
>   
Lists are not matrices. For example:

L = [  [1,2,3], ['a','b','c'], 10 ]
print L[1][2] # Prints 'c', you will like this syntax but...
print L[2][5] # TypeError: 10 is not subscriptable

You can create a function that creates a "list of lists" filled with 
zeros, and then use this data structure as a matrix.

BUT! If you need to use matrices filled with numbers, try numarray:

http://www.stsci.edu/resources/software_hardware/numarray

Numarray is much more efficient for this task.

Best,

   Laszlo




More information about the Python-list mailing list