On Mon, 25 Apr 2011 20:28:22 -0700, Gnarlodious wrote:
> I have an SQLite query that returns a list of tuples:
>
> [('0A',), ('1B',), ('2C',), ('3D',),...
>
> What is the most Pythonic way to loop through the list returning a list
> like this?:
>
> ['0A', '1B', '2C', '3D',...
Others have pointed you at a list comprehension, but just for completion,
there's also this:
from operator import itemgetter
map(itemgetter(0), list_of_tuples)
In Python 3, map becomes lazy and returns an iterator instead of a list,
so you have to wrap it in a call to list().
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list