str = '001,008-011,020'
spl = str.split(',')
output = []
for s in spl:
    if '-' in s:
        rng = s.split('-')
for r in range(int(rng[0]), int(rng[1]) + 1):
    output.append(r)
else:
    output.append(int(s))
print(output)
Expand a string describing a set of numbers noted as a list of numbers and/or ranges