Samuel Muldoon writes:

 > Python's `str` class has a method named `join`
 > 
 > I was wondering if a future release of python could have a `list.join`
 > which behaves in a similar fashion.
 > 
 > result = [99].join([1, 2, 3])
 > print(result)
 > # prints [1, 99, 2, 99, 3]

I wouldn't call that an example of .join.  To me, .join takes an
argument which in the most general case is iterable of iterables.
Your example's argument is the more general iterable of object.  So I
don't think .join is a good name for this function.  Maybe
.interpolate, although that has a different meaning in statistics.

Also, .join "works" for str because it's *not* general.  It's useful
because the "algebra" of strings is built of making lists of strings
and then "flattening" them into a single string.  Encoding the single
string so that it can be "decoded" into the original list of words
involves inserting separator characters such as space, newline, crlf,
or comma.  And that's exactly .join!

I can't think offhand how I would use either a generalized .join or
this function, except with str or bytes, both of which already have
.join.  Do you have an application for either a list join or for this
interpolation function?  .join might be useful in a signal processing
application for the same reason it's useful for strings, but the
interpolation semantics, I don't see it.
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/5ZWQEPN3LIZS5NGCR73RWOKVMTXUSQ3L/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to