def expand_integer(str_range):
    """
    >>> expand_integer('1') == set(['1'])
    True

    >>> expand_integer('1..5,10') == set(['1','2','3','4','5','10'])
    True

    >>> expand_integer('9..3') == set(['3','4','5','6','7','8','9'])
    True

    >>> expand_integer('1..5,8..3') == set(['1','2','3','4','5','6','7','8'])
    True

    >>> expand_integer('try me')
    Traceback (most recent call last):
        ...
    ValueError: integer range 'try me' not parseable

    >>> expand_integer('1..a')
    Traceback (most recent call last):
        ...
    ValueError: integer range '1..a' not parseable

    """
    try:
        answer = set()
        for i_group in str_range.split(','):
            if RANGE_OPERATOR in i_group:
                i_start, i_end = i_group.split(RANGE_OPERATOR)
                if i_start > i_end:
                    i_start, i_end = i_end, i_start
                start_int = parse_integer(i_start)
                end_int = parse_integer(i_end)
                answer |= set(map(str, range(start_int, end_int + 1)))
            else:
                answer.add(str(parse_integer(i_group)))
        return answer
    except __HOLE__:
        raise ValueError("integer range '%s' not parseable" % str_range)
dataset/ETHPy150Open practo/r5d4/r5d4/mapping_functions.py/expand_integer