`join` method for the `list` class ... `list.join`

To Whom it May Concern, 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]* *Samuel Muldoon* *(720) 653 -2408* *muldoonsamuel@gmail.com <muldoonsamuel@gmail.com>*

Samuel Muldoon writes:
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.

This is sometimes a nice function to have. For example, Haskell has a similar function: https://hackage.haskell.org/package/base-4.18.0.0/docs/Data-List.html#v:inte... that I use in real code every once in a while. But I don't think you need to stick this function in the standard library. A third party library works just as well. The only thing missing is that you can't use the `my_list.function_name(other_arguments)| syntax easily, and will call as `function_name(my_list, other_arguments)`. But that seems a small price to pay. On Wed, 7 Jun 2023, 08:00 Samuel Muldoon, <muldoonsamuel@gmail.com> wrote:

more_itertools.interleave(*iterables)[source] Return a new iterable yielding from each iterable in turn, until the shortest is exhausted.
list(interleave([1, 2, 3], [4, 5], [6, 7, 8])) [1, 4, 6, 2, 5, 7]
For a version that doesn’t terminate after the shortest iterable is exhausted, see interleave_longest(). If you want just the same item interleaved, use itertools.repeat(). This approach gets you VASTLY more than the suggestion, but includes it as a trivial case. On Tue, Jun 6, 2023 at 10:09 PM Matthias Görgens < matthias.goergens@gmail.com> wrote:
-- The dead increasingly dominate and strangle both the living and the not-yet born. Vampiric capital and undead corporate persons abuse the lives and control the thoughts of homo faber. Ideas, once born, become abortifacients against new conceptions.

Samuel Muldoon writes:
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.

This is sometimes a nice function to have. For example, Haskell has a similar function: https://hackage.haskell.org/package/base-4.18.0.0/docs/Data-List.html#v:inte... that I use in real code every once in a while. But I don't think you need to stick this function in the standard library. A third party library works just as well. The only thing missing is that you can't use the `my_list.function_name(other_arguments)| syntax easily, and will call as `function_name(my_list, other_arguments)`. But that seems a small price to pay. On Wed, 7 Jun 2023, 08:00 Samuel Muldoon, <muldoonsamuel@gmail.com> wrote:

more_itertools.interleave(*iterables)[source] Return a new iterable yielding from each iterable in turn, until the shortest is exhausted.
list(interleave([1, 2, 3], [4, 5], [6, 7, 8])) [1, 4, 6, 2, 5, 7]
For a version that doesn’t terminate after the shortest iterable is exhausted, see interleave_longest(). If you want just the same item interleaved, use itertools.repeat(). This approach gets you VASTLY more than the suggestion, but includes it as a trivial case. On Tue, Jun 6, 2023 at 10:09 PM Matthias Görgens < matthias.goergens@gmail.com> wrote:
-- The dead increasingly dominate and strangle both the living and the not-yet born. Vampiric capital and undead corporate persons abuse the lives and control the thoughts of homo faber. Ideas, once born, become abortifacients against new conceptions.
participants (4)
-
David Mertz, Ph.D.
-
Matthias Görgens
-
Samuel Muldoon
-
Stephen J. Turnbull