Skip to main content

A data structure for dealing with sets of ranges.

Project description

Build Status


Rangeset is a package that allows for easy manipulation of sets of ranges. These ranges can contain any ordered elements, be they numbers, tuples, or even datetime objects.


Use either:

python install


pip install rangeset


See <>__

Basic Usage

import rangeset

# Create a rangeset
>>> r = RangeSet(1, 3) | (5, 6)

# negate
>>> (~r) & (0, 10)
<RangeSet 0 -- 1, 3 -- 5, 6 -- 10>

# "measure" - How much distance is in the ranges, minus the gaps
>>> ((~r) & (0, 10)).measure()

# range - Total distance between start and end
>>> ((~r) & (0, 10)).range()

For more usage examples, see the doctests at


It’s licensed under the MIT License. Please see the license file for more:

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rangeset-0.0.14.linux-x86_64.tar.gz (8.8 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page