splice_between_elements

sequencetools.splice_between_elements(sequence, new_elements, overhang=(0, 0))

Splices copies of new_elements between each of the elements of sequence.

>>> sequence = [0, 1, 2, 3, 4]
>>> new_elements = ['A', 'B']

Example 1. Splices characters between integers:

>>> sequencetools.splice_between_elements(sequence, new_elements)
[0, 'A', 'B', 1, 'A', 'B', 2, 'A', 'B', 3, 'A', 'B', 4]

Example 2. Splices copies of new_elements between each of the elements of sequence and after the last element of sequence:

>>> sequencetools.splice_between_elements(
...     sequence, new_elements, overhang=(0, 1))
[0, 'A', 'B', 1, 'A', 'B', 2, 'A', 'B', 3, 'A', 'B', 4, 'A', 'B']

Example 3. Splices copies of new_elements before the first element of sequence and between each of the other elements of sequence:

>>> sequencetools.splice_between_elements(
...     sequence, new_elements, overhang=(1, 0))
['A', 'B', 0, 'A', 'B', 1, 'A', 'B', 2, 'A', 'B', 3, 'A', 'B', 4]

Example 4. Splices copies of new_elements before the first element of sequence, after the last element of sequence and between each of the other elements of sequence:

>>> sequencetools.splice_between_elements(
...     sequence, new_elements, overhang=(1, 1))
['A', 'B', 0, 'A', 'B', 1, 'A', 'B', 2, 'A', 'B', 3, 'A', 'B', 4, 'A', 'B']

Returns new object of sequence type.