Skip to content

Replace range parsing logic with a 3rd party library #15

@chriscarrollsmith

Description

@chriscarrollsmith

Looks like ranges will do this out of the box:

from ranges import Range

# Convert list to ranges
nums = [1, 2, 3, 5, 7, 8, 9, 12]
r = Range(*nums)
print(r)  # Range(1, 4) + Range(5, 6) + Range(7, 10) + Range(12, 13)

# Convert back to list
list(r)  # [1, 2, 3, 5, 7, 8, 9, 12]

# String representation
str(r)  # "1-3,5,7-9,12"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions