This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author steven.daprano
Recipients Phillip.M.Feldman@gmail.com, mpaolini, steven.daprano
Date 2020-09-07.22:16:23
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1599516983.75.0.295746236329.issue41740@roundup.psfhosted.org>
In-reply-to
Content
As Marco says, the exception message is because the default value for start is 0, and you can't concatenate strings to the integer 0.

You get the same error if you try to concatenate lists:

    py> sum([[], []])
    TypeError: unsupported operand type(s) for +: 'int' and 'list'


However, even if you provide a default of the empty string, "", sum will still reject string arguments. This is intentional, as repeatedly concatenating strings may be extremely inefficient and slow, depending on the specific circumstances.


The default of 0 is documented, as is the intention that sum be used only for numeric addition. See `help(sum)` or the docs on the website.
History
Date User Action Args
2020-09-07 22:16:23steven.dapranosetrecipients: + steven.daprano, Phillip.M.Feldman@gmail.com, mpaolini
2020-09-07 22:16:23steven.dapranosetmessageid: <1599516983.75.0.295746236329.issue41740@roundup.psfhosted.org>
2020-09-07 22:16:23steven.dapranolinkissue41740 messages
2020-09-07 22:16:23steven.dapranocreate