repeat_sequence_to_weight

sequencetools.repeat_sequence_to_weight(sequence, weight, allow_total=Exact)

Repeats sequence to weight.

Example 1. Repeats sequence to weight of 23 exactly:

>>> sequencetools.repeat_sequence_to_weight((5, -5, -5), 23)
(5, -5, -5, 5, -3)

Truncates last element when necessary.

Example 2. Repeats sequence to weight of 23 more:

>>> sequencetools.repeat_sequence_to_weight(
...     (5, -5, -5),
...     23,
...     allow_total=More,
...     )
(5, -5, -5, 5, -5)

Does not truncate last element.

Example 3. Repeats sequence to weight of 23 or less:

>>> sequencetools.repeat_sequence_to_weight(
...     (5, -5, -5),
...     23,
...     allow_total=Less,
...     )
(5, -5, -5, 5)

Discards last element when necessary.

Returns new object of sequence type.