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

Jamesie Pic jpic at yourlabs.org
Wed Jan 30 05:31:46 EST 2019

On Wed, Jan 30, 2019 at 11:24 AM Eric V. Smith <eric at trueblade.com> wrote:
> Your examples show literals, but I literally (heh) never use str.join
> this way. I always pass it some variable. And 100% of the time, if that
> variable (say it's a list) contains something that's not a string, I
> want it to raise an exception. I do not want this to succeed:
> lst = ['hello', None]
> ', '.join(lst)
> lst is usually computed a long way from where the join happens.
> So, I do not want this task automated for me.

That's a really good point ! So, maybe we have a parameter for that ...

from implode import implode

assert implode('-', [3, None, 2], none_str='') == '3-2'

Even that still seems pretty fuzzy to me, please, can you share an
idea for improvement ?


More information about the Python-ideas mailing list