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

Jamesie Pic jpic at yourlabs.org
Tue Jan 29 12:34:31 EST 2019

funcoperators is pretty neat ! But at this stage of the discussion I
would also try to get automatic string casting since the purpose is to
assemble a string.

It would be great in the stdlib because switching between os.path.join
and str.join is so error-prone, and assembling strings seems like a
pretty common task. It's not uncommon to find str.join in arguments
against Python.

Monkey patching str in PYTHONTARTUP.py would work, but then that would
require users pulling my package to also hack their startup script. Or
even worse: we could patch the startup script upon package
installation. It seems like it would make redistribution a lot harder
than it should.

Another approach would be to add a stringify(delim='\n') method to
iterables, it would accept a delimiter argument and would return a
string of all items casted to string and separated by the delimiter.

That would be certainly more backward-compatible than supporting an
alternate str.join(1, 'b') call.

Meanwhile I've opened a PR on boltons, but, well, it looks a lot like
php.net/implode, and I'm not really sure we want that :D



More information about the Python-ideas mailing list