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 terry.reedy
Recipients BTaskaya, EmilStenstrom, eric.smith, jack1142, mrabarnett, pablogsal, rhettinger, serhiy.storchaka, terry.reedy, veky, xtreak
Date 2021-03-20.21:28:24
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1616275704.68.0.17074531942.issue43535@roundup.psfhosted.org>
In-reply-to
Content
I read all the responses as of this timestamp. They left me more persuaded that joining objects with a string (or bytes) is explicit enough that the objects *must* be coerced to strings.

A problem with coercion in "1 + '2'" is that there is no 'must'.  The desired answer could be either 3 or '12', and neither can be converted to the other, so don't guess.

The desired answer for "1 + .5" is much more obviously 1.5 rather than either 1 or 2, plus the former avoids information loss and leaves the option available of rounding or converting however one wants.

One tweet answered my question about masking a bug. Suppose 'words' is intended to be an iterable of strings.

>>> words = ['This', 'is', 'a', 'list', 'of', 7, 'words']  # Buggy
>>> print(*words)  # Auto-coercion masks the bug.
This is a list of 7 words
>>> '-'.join(words)  # Current .join does not.
Traceback (most recent call last):
  File "<pyshell#8>", line 1, in <module>
    '-'.join(words)
TypeError: sequence item 5: expected str instance, int found

With the proposed change, detection of the bug is delayed, as is already the case with print.  How much do we care about this possibility?  One possible answer is to add a new method, such as 'joins' or builtin function 'join'.

Given the variety of opinions, I think a PEP and SC decision would be needed.
History
Date User Action Args
2021-03-20 21:28:24terry.reedysetrecipients: + terry.reedy, rhettinger, eric.smith, mrabarnett, serhiy.storchaka, veky, pablogsal, xtreak, BTaskaya, EmilStenstrom, jack1142
2021-03-20 21:28:24terry.reedysetmessageid: <1616275704.68.0.17074531942.issue43535@roundup.psfhosted.org>
2021-03-20 21:28:24terry.reedylinkissue43535 messages
2021-03-20 21:28:24terry.reedycreate