Vlastimil Brom wrote:
2009/8/28 hoffik <be...@seznam.cz>:
Hello,
I'm quite new in Python and I have one question. I have a 2D matrix of
values stored in list (3 columns, many rows). I wonder if I can select one
column without having to go through the list with 'for' command.
...
I guess, it won't be possible without an explicit or implicit loop;
you may try:
from operator import itemgetter
nested_list = [[1, 2, 3], [10, 20, 30], [100, 200, 300]]
map(itemgetter(1), nested_list)
[2, 20, 200]
vbr
How about rotating the list with zip?
>>> zip (*nested_list)[1]
(2, 20, 200)
Frederic
--
http://mail.python.org/mailman/listinfo/python-list