De-tupleizing a list

Paul Rubin no.email at nospam.invalid
Tue Apr 26 00:08:49 EDT 2011


Gnarlodious <gnarlodious at gmail.com> writes:
> 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',...

Try:

    tlist = [('0A',), ('1B',), ('2C',), ('3D',)]
    alist = [x for (x,) in tlist]



More information about the Python-list mailing list