|
|
|
|
|
by blixt
3204 days ago
|
|
I guess sum was only implemented to support numeric values. However you can easily roll your own: >>> def add(it):
... return reduce(lambda x, y: x + y, it)
...
>>> add(['hello ', 'world'])
'hello world'
>>> add(x for x in xrange(10))
45
Edit: almost forgot a possibly even more Pythonic way: >>> import operator
>>> def add(it):
... return reduce(operator.add, it)
|
|