how to flatten one level of list of lists?
George Young
gry at ll.mit.edu
Tue May 29 13:36:12 EDT 2001
I have a list like:
l = [[2], [3], [5], [11]]
and I want to get:
ll = [2, 3, 5, 11]
I know I can do something like:
ll = map(lambda i: i[0],l)
but it seems like overkill to have to use a lamba for such a simple
task.
Is there some easy way I'm missing?
BTW, I tried to use l.__getitem__ or l.__getslice__ with map, but both
failed with AttributeError. (this is python 2.1) The 2.1 docs seem to
say these members exist for
lists -- what's wrong?
Thanks,
George
--
Your mouse has moved.
Windows NT must be restarted for the change to take effect.
Reboot now? [OK]
More information about the Python-list
mailing list