# partition_sequence_by_weights¶

`sequencetools.``partition_sequence_by_weights`(sequence, weights, cyclic=False, overhang=False, allow_part_weights=Exact)

Partitions sequence by weights exactly.

```>>> sequence = [3, 3, 3, 3, 4, 4, 4, 4, 5]
```

Example 1. Partitions sequence once by weights: overhang:

```>>> sequencetools.partition_sequence_by_weights(
...     sequence,
...     [3, 9],
...     cyclic=False,
...     overhang=False,
...     )
[[3], [3, 3, 3]]
```

Example 2. Partitions sequence once by weights. Allows overhang:

```>>> sequencetools.partition_sequence_by_weights(
...     sequence,
...     [3, 9],
...     cyclic=False,
...     overhang=True,
...     )
[[3], [3, 3, 3], [4, 4, 4, 4, 5]]
```

Example 3. Partitions sequence cyclically by weights:

```>>> sequencetools.partition_sequence_by_weights(
...     sequence,
...     [12],
...     cyclic=True,
...     overhang=False,
...     )
[[3, 3, 3, 3], [4, 4, 4]]
```

Example 4. Partitions sequence cyclically by weights. Allows overhang:

```>>> sequencetools.partition_sequence_by_weights(
...     sequence,
...     [12],
...     cyclic=True,
...     overhang=True,
...     )
[[3, 3, 3, 3], [4, 4, 4], [4, 5]]
```
```>>> sequence = [3, 3, 3, 3, 4, 4, 4, 4, 5, 5]
```

Example 5. Partitions sequence once by weights. Allows part weights to be just less than specified:

```>>> sequencetools.partition_sequence_by_weights(
...     sequence,
...     [10, 4],
...     cyclic=False,
...     overhang=False,
...     allow_part_weights=Less,
...     )
[[3, 3, 3], [3]]
```

Example 6. Partitions sequence once by weights. Allows part weights to be just less than specified. Allows overhang:

```>>> sequencetools.partition_sequence_by_weights(
...     sequence,
...     [10, 4],
...     cyclic=False,
...     overhang=True,
...     allow_part_weights=Less,
...     )
[[3, 3, 3], [3], [4, 4, 4, 4, 5, 5]]
```

Example 7. Partitions sequence cyclically by weights. Allows part weights to be just less than specified:

```>>> sequencetools.partition_sequence_by_weights(
...     sequence,
...     [10, 5],
...     cyclic=True,
...     overhang=False,
...     allow_part_weights=Less,
...     )
[[3, 3, 3], [3], [4, 4], [4], [4, 5], [5]]
```

Example 8. Partitions sequence cyclically by weights. Allows part weights to be just less than specified. Allows overhang:

```>>> sequencetools.partition_sequence_by_weights(
...     sequence,
...     [10, 5],
...     cyclic=True,
...     overhang=True,
...     allow_part_weights=Less,
...     )
[[3, 3, 3], [3], [4, 4], [4], [4, 5], [5]]
```
```>>> sequence = [3, 3, 3, 3, 4, 4, 4, 4, 5, 5]
```

Example 9. Partitions sequence once by weights. Allow part weights to be just more than specified:

```>>> sequencetools.partition_sequence_by_weights(
...     sequence,
...     [10, 4],
...     cyclic=False,
...     overhang=False,
...     allow_part_weights=More,
...     )
[[3, 3, 3, 3], [4]]
```

Example 10. Partitions sequence once by weights. Allows part weights to be just more than specified. Allows overhang:

```>>> sequencetools.partition_sequence_by_weights(
...     sequence,
...     [10, 4],
...     cyclic=False,
...     overhang=True,
...     allow_part_weights=More,
...     )
[[3, 3, 3, 3], [4], [4, 4, 4, 5, 5]]
```

Example 11. Partitions sequence cyclically by weights. Allows part weights to be just more than specified:

```>>> sequencetools.partition_sequence_by_weights(
...     sequence,
...     [10, 4],
...     cyclic=True,
...     overhang=False,
...     allow_part_weights=More,
...     )
[[3, 3, 3, 3], [4], [4, 4, 4], [5]]
```

Example 12. Partitions sequence cyclically by weights. Allows part weights to be just more than specified. Allows overhang:

```>>> sequencetools.partition_sequence_by_weights(
...     sequence,
...     [10, 4],
...     cyclic=True,
...     overhang=True,
...     allow_part_weights=More,
...     )
[[3, 3, 3, 3], [4], [4, 4, 4], [5], [5]]
```

Returns list of sequence objects.