Indexing list of lists
David C. Fox
davidcfox at post.harvard.edu
Thu Sep 18 14:25:19 EDT 2003
Hilde Roth wrote:
>>Like it or not, there are no "different dimensions", just lists of lists
>>of lists...
>
>
> You are being too litteral. A list of list is like a 2D array from an
> indexing point of view, a list of lists of lists like a 3D array etc.
> E.g., (((1,10),(2,20),(3,30)),((-1,'A'),(-2,'B'),(-3,'C'))) is a
> 2 x 3 x 2 rectangular data structure and has 3 dimensions. Hence,
> e.g., l[0;2;1] ~ l[0][2][1] = 30
Only if all the sublists are of the same length, which is guaranteed for
a multi-dimensional array, but not for a list of lists.
What do you expect a[;1] to return if a = [[], [1, 2, 3], [4], 5]?
That's why Numeric has a specific type for multi-dimensional arrays.
David
More information about the Python-list
mailing list