[Python-ideas] Add list.join() please

Barry Scott barry at barrys-emacs.org
Wed Jan 30 13:31:09 EST 2019



> On 30 Jan 2019, at 10:07, Jamesie Pic <jpic at yourlabs.org> wrote:
> 
> On Wed, Jan 30, 2019 at 7:03 AM Robert Vanden Eynde
> <robertve92 at gmail.com> wrote:
>>> 
>>> Raises an error. Why should:
>>> 
>>> “”.join([2, “2”]) not raise an error as well?
>> 
>> I agree
> 
> What do you think could be the developer intent when they do
> ",".join([2, "2']) ?
> 
> If the intent is clearly to assemble a string, as it looks like, then
> I don't find any disadvantage to automate this task for them.

The intent is not clear. How is the 2 to be formatted?

I fixed a nasty bug recently where a join of a list of strings contained a non-string in some cases.
If the str(bad_value) had been the default I would not have been able to track this down from the
traceback in a few minutes.

I'm -1 on this idea as it would hide bugs in my experience.

Barry


> 
> -- 
>> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/



More information about the Python-ideas mailing list