def list_to_ranges(values):
    range_groups = []
    for _, g in groupby(enumerate(values), lambda (i, x): i - x):
        range_groups.append(map(itemgetter(1), g))
    range_strings = []
    for group in range_groups:
        if len(group) == 1:
            range_strings.append(str(group[0]))
        else:
            range_strings.append('{}-{}'.format(group[0], group[-1]))
    return ','.join(range_strings)
Open port
dataset/ETHPy150Open ARM-software/workload-automation/wlauto/utils/misc.py/list_to_ranges--crossover with--dataset/ETHPy150Open LabPy/lantz/lantz/drivers/legacy/serial.py/SerialDriver.initialize