On Dec 30, 11:41 am, 5lvqbw...@sneakemail.com wrote: > > >>> conc = lambda x,y: x[:] + y # concatenate 2 lists without side effects > >>> mylist = ['something\n', 'another something\n', 'something again\n'] > >>> myvar = reduce(conc, mylist) > >>> print myvar >
"conc"? "side effects"? Missing Lisp much? ;-) Let's try to Pythonize your lisp. One: Assigning a lambda to a variable? Just use def. It's pretty much the same thing. >>> def conc(x,y): return x[:]+y Two: I don't think x+y affects x at all when x and y are lists. (Is that a lispism?) So x[:]+y has an unnecessary array copy. >>> def conc(x,y): return x+y Three: Python may still be slow at string concatenation. (Perl is fast.) Rather than concatenating one at a time, it's better, I understand, to build up a list and then join() them together. The other posters got the right answer in the pythonic way. -- http://mail.python.org/mailman/listinfo/python-list