[Tutor] flattening a list

Bill Kranec billk at fastmail.fm
Wed Jan 12 05:00:45 CET 2005


Hello,

I have a list of lists, for example [ [1,2] , [3,4] ], and I would like 
to pass all the elements of that list as arguments to a function (for 
example the intersection of all list elements).  Is there a command in 
regular Python to do this?  I would like to avoid the hassle and speed 
hit of a loop to extract all the list elements.

In the past, I believe I have used something like flatten(list), which 
was part of Numarray (I think).  Am I missing an obvious or clever 
solution in regular Python?

Thanks for your help!

Bill


More information about the Tutor mailing list