Q:

How do I convert tuple of tuples to list in one line (pythonic)?

query = 'select mydata from mytable'
cursor.execute(query)
myoutput = cursor.fetchall() 
print myoutput

(('aa',), ('bb',), ('cc',))

Why is it (cursor.fetchall) returning a tuple of tuples instead of a tuple since my query is asking for only one column of data?
What is the best way of converting it to ['aa', 'bb', 'cc'] ?
I can do something like this :
mylist = []
myoutput = list(myoutput)
for each in myoutput:
   mylist.append(each[0])

I am sure this isn't the best way of doing it. Please enlighten me!

A:

This works as well:
>>> tu = (('aa',), ('bb',), ('cc',))
>>> import itertools
>>> list(itertools.chain(*tu))
['aa', 'bb', 'cc']

Edit Could you please comment on the cost tradeoff? (for loop and itertools)
Itertools is significantly faster:
>>> t = timeit.Timer(stmt="itertools.chain(*(('aa',), ('bb',), ('cc',)))")
>>> print t.timeit()
0.341422080994
>>> t = timeit.Timer(stmt="[a[0] for a in (('aa',), ('bb',), ('cc',))]")
>>> print t.timeit()
0.575773954391

Edit 2 Could you pl explain itertools.chain(*)
That * unpacks the sequence into positional arguments, in this case a nested tuple of tuples. 
Example:
>>> def f(*args):
...    print "len args:",len(args)
...    for a in args:
...       print a
... 
>>> tu = (('aa',), ('bb',), ('cc',))
>>> f(tu)
len args: 1
(('aa',), ('bb',), ('cc',))
>>> f(*tu)
len args: 3
('aa',)
('bb',)
('cc',)

Another example:
>>> f('abcde')
len args: 1
abcde
>>> f(*'abcde')
len args: 5
a
b
c
d
e

See the documents on unpacking.

A:

You could do
>>> tup = (('aa',), ('bb',), ('cc',))
>>> lst = [a[0] for a in tup]
>>> lst
['aa', 'bb', 'cc']

