zip_sequences

sequencetools.zip_sequences(iterables, cyclic=False, truncate=True)

Zips iterables.

Example 1. Zips two iterables cyclically:

>>> iterables = [[1, 2, 3], ['a', 'b']]
>>> sequencetools.zip_sequences(iterables, cyclic=True)
[(1, 'a'), (2, 'b'), (3, 'a')]

Example 2. Zips three iterables cyclically:

>>> iterables = [[10, 11, 12], [20, 21], [30, 31, 32, 33]]
>>> sequencetools.zip_sequences(iterables, cyclic=True)
[(10, 20, 30), (11, 21, 31), (12, 20, 32), (10, 21, 33)]

Example 3. Zips iterables without truncation:

>>> iterables = ([1, 2, 3, 4], [11, 12, 13], [21, 22, 23])
>>> sequencetools.zip_sequences(iterables, truncate=False)
((1, 11, 21), (2, 12, 22), (3, 13, 23), (4,))

** Example 4.** Zips iterables noncyclically and with truncation. Equivalent to built-in zip():

>>> iterables = ([1, 2, 3, 4], [11, 12, 13], [21, 22, 23])
>>> sequencetools.zip_sequences(iterables)
((1, 11, 21), (2, 12, 22), (3, 13, 23))

Returns new object of iterables type.