In article <0062f568$0$26941$c3e8...@news.astraweb.com>, Steven D'Aprano <st...@remove-this-cybersource.com.au> wrote: > >Mathematically, sum() is defined as the repeated application of the + >operator. In Python, the + operator is well-defined for strings and lists >as well as numbers. Since you can say "ab" + "cd" + "ef" and get a >sensible result, then sum() should be able to do the same thing. > >And indeed, if you pass a list-of-lists to sum(), it does: > >>>> sum([[1,2], ['a',None], [1,'b']], []) >[1, 2, 'a', None, 1, 'b'] > >(For the record, summing lists is O(N**2), and unlike strings, there's no >optimization in CPython to avoid the slow behaviour.)
Are you sure? -- Aahz (a...@pythoncraft.com) <*> http://www.pythoncraft.com/ "To me vi is Zen. To use vi is to practice zen. Every command is a koan. Profound to the user, unintelligible to the uninitiated. You discover truth everytime you use it." --re...@lion.austin.ibm.com -- http://mail.python.org/mailman/listinfo/python-list