[issue41740] Improve error message for string concatenation via `sum`

Steven D'Aprano report at bugs.python.org
Mon Sep 7 18:24:45 EDT 2020


Steven D'Aprano <steve+python at pearwood.info> added the comment:

Marco, sum should be as fast as possible, so we don't want to type check every single element. But if it is easy enough, it might be worth checking the first element, and if it fails, report:

    cannot add 'type' to start value

where 'type' is the type of the first element. If that is str, then concatenate

    (use ''.join(iterable) instead)

to the error message.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue41740>
_______________________________________


More information about the Python-bugs-list mailing list