[Python-ideas] Add list.join() please
MRAB
python at mrabarnett.plus.com
Tue Jan 29 19:14:51 EST 2019
On 2019-01-29 23:38, Greg Ewing wrote:
> Brendan Barnwell wrote:
>> Personally what I find is perverse is that .join is a method of
>> strings but does NOT call str() on the items to be joined.
>
> Neither do most other string methods:
>
> >>> s = "hovercraft"
> >>> s.count(42)
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> TypeError: Can't convert 'int' object to str implicitly
>
> Why should join() be any different?
>
And what if you don't want str, but instead repr, or ascii?
(An optional stringifying function, maybe? :-))
More information about the Python-ideas
mailing list