This looks like a job for List Comprehensions! >>> list = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] >>> new_list = [item[1] for item in list] >>> new_list [2, 5, 8] >>>
looks good? Ian On 8/21/07, Orest Kozyar <[EMAIL PROTECTED]> wrote: > > I've got a "2D" list (essentially a list of lists where all sublists are > of > the same length). The sublists are polymorphic. One "2D" list I commonly > work with is: > > [ [datetime object, float, int, float], > [datetime object, float, int, float], > [datetime object, float, int, float] ] > > I'd like to be able to quickly accumulate the datetime column into a list. > Is there a simple/straightforward syntax (such as list[:][0]) to do this, > or > do we need to use a for loop? I expect what I have in mind is similar to > the Python array type, except it would be polymorphic. > > Thanks, > Orest > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor >
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor