list of lists

Mel Wilson mwilson at the-wire.com
Mon Sep 15 10:51:25 EDT 2003


In article <bk4grj$me3$1 at news.uni-kl.de>, Tom <llafba at gmx.net> wrote:
>I have a list that consists of lists.
>E.g. T=[[1, 2, 3], [4, 5], [6]]
>Is there a way to address the a specific component in the "inner" list
>directly?
>E.g. right now I want to get the second value of the first list.
>Unfortunately I have to save it to a variable first and then read it.
>a = T[0]
>print a[1]

Anybody? :)

print T[0][1]

   Python syntax is pretty regular.  If T is a list, then
T[0] is the zero-th element of T. If T[0] is a list, then
T[0][1] is the 1-th element of T[0].  Works for tuples and
dictionaries too.

   Hairier, if F(a) returns a function object based somehow
on the value of a, then F(a)(b) will call that function with
an argument of b. And so, on and on.  Tuples of functions?
Functions returning dictionaries caching lists of functions?
...

        Regards.        Mel.




More information about the Python-list mailing list