De-tupleizing a list

John Connor john.theman.connor at
Tue Apr 26 00:29:31 EDT 2011

itertools can help you do this too:

import itertools
tl = [('0A',), ('1B',), ('2C',), ('3D',)]

<itertools.chain object at 0x11f7ad0>

['0A', '1B', '2C', '3D']

for more info.

On Mon, Apr 25, 2011 at 11:08 PM, Paul Rubin < at nospam.invalid> wrote:
> Gnarlodious <gnarlodious at> 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