Thought you might enjoy my super-small flatten function: (though google groups seems to be munging my whitespace today) def flatten(d): "flatten([[[1,[2,3],[4,5]],6],[7]])==[1,2,3,4,5,6,7]" return reduce(lambda a,b:a+b,[(type(x) in (list, tuple) \ and flatten(x) or [x]) for x in d])