def range_split(hosts):
    in_brackets = False
    current = ""
    result_list = []
    for c in hosts:
        if c in ['[']:
            in_brackets = True
        if c in [']']:
            in_brackets = False
        if not in_brackets and c == ',':
            result_list.append(current)
            current = ""
        # elif not in_brackets and c == '-':
        #     result_list.append(current)
        #     result_list.append('-')
        #     current = ""
        elif not in_brackets and c in [','] and len(current) == 0:
            pass
        else:
            current += c
    current = current.strip().strip(',')
    if current:
        result_list.append(current)
    return result_list
Split up a range string, this needs to separate comma separated
dataset/ETHPy150Open dwighthubbard/hostlists/hostlists/hostlists.py/range_split