[Python-Dev] Usage of += on strings in loops in stdlib (original) (raw)
Xavier Morel python-dev at masklinn.net
Wed Feb 13 12:46:33 CET 2013
- Previous message: [Python-Dev] Usage of += on strings in loops in stdlib
- Next message: [Python-Dev] Usage of += on strings in loops in stdlib
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 2013-02-13, at 12:37 , Steven D'Aprano wrote:
# even less obvious than sum map(operator.add, array)
That one does not work, it'll try to call the binary add
with each
item of the array when the map iterator is reified, erroring out.
functools.reduce(operator.add, array, '')
would work though, it's an other way to spell sum
without the
string prohibition.
- Previous message: [Python-Dev] Usage of += on strings in loops in stdlib
- Next message: [Python-Dev] Usage of += on strings in loops in stdlib
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]