finesse.script.util.index_ranges

finesse.script.util.index_ranges(intlist)[source]

Create a sequence of range strings from a sequence of integers.

Based on https://stackoverflow.com/a/9471386/2251982.

Parameters:
intlistsequence

Integers to convert to range strings.

Yields:
str

The next range string.

Examples

>>> list(index_ranges([1, 2, 4, 5, 6, 7, 9]))
["1-2", "4-7", "9"]