I'm probably missing something simple here but is there anyway to
accomplish the following with a list comprehension?

def get_clists():
    return [1, 2, 3]

def get_clist(num):
    if num == 1:
        return ['a', 'b', 'c']
    if num == 2:
        return ['x', 'y', 'z']
    if num == 3:
        return ['p', 'q']

files = list()
for clist in get_clists():
    files += get_clist(clist)

My first attempt was to try 
[get_clist(c) for c in get_clists()]

but this returns a list of lists rather than the flat list from the
original.

Any help is appreciate...just trying to be as Pythonesque as possible
:-)

Jeff

_______________________________________________
Tutor maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/tutor

Reply via email to