On 9/10/12 04:39:28, rusi wrote: > On Oct 9, 7:34 am, rusi <rustompm...@gmail.com> wrote: >> How about a 2-paren version? >> >>>>> x = [1,2,3] >>>>> reduce(operator.add, [['insert', a] for a in x]) >> >> ['insert', 1, 'insert', 2, 'insert', 3] > > Or if one prefers the different parens on the other side: > >>>> reduce(operator.add, (['insert', a] for a in x)) > ['insert', 1, 'insert', 2, 'insert', 3]
Or, if you don't want to import the operator module: sum((['insert', a] for a in x), []) -- HansM -- http://mail.python.org/mailman/listinfo/python-list