[Python-ideas] The non-obvious nature of str.join (was Re: sum(...) limitation)

Stephen Hansen me+python at ixokai.io
Mon Aug 11 18:37:39 CEST 2014


On Mon, Aug 11, 2014 at 9:22 AM, Alexander Belopolsky <
alexander.belopolsky at gmail.com> wrote:

>
> On Mon, Aug 11, 2014 at 11:55 AM, Todd <toddrjen at gmail.com> wrote:
>
>> In my experience, it is the asymmetry between x.join(y) and x.split(y)
>>> which causes most of the confusion.  In x.join(y), x is the separator and y
>>> is the data being joined, but in x.split(y), it is the other way around.
>>>
>>
>> What would be the solution to this?
>>
>
> Allow sum(list_of_strings, '') and stop mocking people who prefer it to
> ''.join(..).  This will not solve all the issues with join/split, but at
> least a simple task of concatenating a list of strings will have a more or
> less obvious solution.
>

Then we'll have two obvious solutions since "".join() and the huge body of
code using it won't go away. One which is only even vaguely workable
because of an implementation-specific optimization that isn't a promise of
the language, which makes it at best obvious* if not obvious-ish.

>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20140811/694b9902/attachment.html>


More information about the Python-ideas mailing list