[Python-ideas] Add list.join() please
Robert Vanden Eynde
robertve92 at gmail.com
Tue Jan 29 10:20:17 EST 2019
So you'd propose to add some kind of
def Join(sep, *args):
return sep.join(map(str, args))
To the standard lib ?
Or to add another method to str class that do that ?
def Join(self, *args):
return self.join(map(str, args))
I agree such a function is super convenient but does it need to be added to
the standard lib I have it in my custom utils.py and my PYTHONTARTUP.py
file so that I can use it everywhere.
Call it Join, superjoin, joinargs...
On Tue, 29 Jan 2019, 02:43 Jamesie Pic <jpic at yourlabs.org wrote:
> During the last 10 years, Python has made steady progress in convenience
> to assemble strings. However, it seems to me that joining is still, when
> possible, the cleanest way to code string assembly.
> However, I'm still sometimes confused between the different syntaxes used
> by join methods:
> 0. os.path.join takes *args
> 1. str.join takes a list argument, this inconsistence make it easy to
> mistake with the os.path.join signature
> Also, I still think that:
> '_'.join(['cancel', name])
> Would be more readable as such:
> ['cancel', name].join('_')
> Not only this would fix both of my issues with the current status-quo, but
> this would also be completely backward compatible, and probably not very
> hard to implement: just add a join method to list.
> Thanks in advance for your reply
> Have a great day
> Python-ideas mailing list
> Python-ideas at python.org
> Code of Conduct: http://python.org/psf/codeofconduct/
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-ideas