MCPcopy
hub / github.com/stas00/ml-engineering / list2range

Function list2range

debug/tiny-scripts/general-pmd-ds-unpack.py:48–55  ·  view source on GitHub ↗

list2range('1,2,5-7,10') [1, 2, 5, 6, 7, 10] # from https://stackoverflow.com/a/6405711/9201239

(s)

Source from the content-addressed store, hash-verified

46args = parser.parse_args()
47
48def list2range(s):
49 """
50 list2range('1,2,5-7,10')
51 [1, 2, 5, 6, 7, 10]
52 # from https://stackoverflow.com/a/6405711/9201239
53 """
54 return sum(((list(range(*[int(j) + k for k,j in enumerate(i.split('-'))]))
55 if '-' in i else [int(i)]) for i in s.split(',')), [])
56
57def unpack(args, idx, row):
58 #pprint(row)

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected