De-tupleizing a list

Gnarlodious gnarlodious at
Tue Apr 26 08:19:08 EDT 2011

On Apr 25, 10:59 pm, Steven D'Aprano wrote:

> 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().

Ah, thanks for that tip. Also works for outputting a tuple:
list_of_tuples=[('0A',), ('1B',), ('2C',), ('3D',)]

(x for (x,) in list_of_tuples)
<generator object <genexpr> at 0x1081ee0>

tuple(x for (x,) in list_of_tuples)

Thanks everyone for the abundant help.

-- Gnarlie

More information about the Python-list mailing list