A rangeset utility for python
Python JavaScript Shell
Switch branches/tags
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
docs
python2/rangeset
python3/rangeset
sources
static
.gitignore
.travis.yml
AUTHORS
CHANGELOG
LICENSE
README
README.md
genindex.html
index.html
objects.inv
search.html
searchindex.js
setup.py

README.md

rangeset - A utility belt for operations on sets of ranges

Build Status

Overview

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.

Installation

Use either:

python setup.py install

or:

pip install rangeset

Documentation

See http://axiak.github.com/py-rangeset

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()
7

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

For more usage examples, see the doctests at https://github.com/axiak/py-rangeset/tree/master/python2/rangeset/test

License

It's licensed under the MIT License. Please see the license file for more: https://github.com/axiak/py-rangeset/blob/master/LICENSE