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

David Mertz mertz at gnosis.cx
Mon Jan 28 21:22:37 EST 2019

On Mon, Jan 28, 2019 at 8:44 PM Jamesie Pic <jpic at yourlabs.org> wrote:

> ['cancel', name].join('_')

This is a frequent suggestion.  It is also one that makes no sense
whatsoever if you think about Python's semantics.  What would you expect to
happen with this line:

['foo', b'foo', 37, re.compile('foo')].join('_')

 List are not restricted to containing only strings (or things that are
string-like enough that they might play well with joining).  Growing a
method that pertains only to that specialized sort of list breaks the
mental model of Python.  Moreover, there is no way to TELL if a particular
list is a "list of strings" other than checking each item inside it (unlike
in many languages).

Keeping medicines from the bloodstreams of the sick; food
from the bellies of the hungry; books from the hands of the
uneducated; technology from the underdeveloped; and putting
advocates of freedom in prisons.  Intellectual property is
to the 21st century what the slave trade was to the 16th.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20190128/0ff851e4/attachment.html>

More information about the Python-ideas mailing list