def expand_specs(specs):
    """
    Example: ['foo', 'a^1-3', 'bar'] => ['foo', 'a^1', 'a^2', 'a^3', 'bar']
    """ 
    new_specs = []
    for spec in specs:
        m = HISTORY_RANGE_REGEX.match(spec)
        if m:
            a, b = int(m.group(2)), int(m.group(3))
            for i in range(a, b + 1) if a <= b else range(a, b-1, -1):
                new_specs.append(m.group(1) + str(i))
        else:
            new_specs.append(spec)
    return new_specs
dataset/ETHPy150Open codalab/codalab-cli/codalab/lib/spec_util.py/expand_specs/original