Two dimensional lists
Travis Oliphant
oliphant.travis at ieee.org
Thu Jan 25 12:58:40 EST 2007
Laszlo Nagy wrote:
>># 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.
It is also out-dated. For new code users are strongly encouraged to use
NumPy. The numarray people are transitioning their own code to use
NumPy and numarray will cease being supported at some point.
http://numpy.scipy.org
http://www.numpy.org --- sourceforge site.
-Travis
More information about the Python-list
mailing list