Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a discontinuous range class for Python?

Tags:

python

I'd like to represent an arbitrarily complex range of real values, which can be discontinuous, i.e.:

0--4 and 5--6 and 7.12423--8

Where I'll be adding new ranges incrementally:

(0--4 and 5--6 and 7.12423--8) | ( 2--7) = (0--7 and 7.12423--8)

I don't really know the right language to describe this, so I'm struggling to search, but it seems like a class probably already exists to do what I want to do. Does it?

like image 297
James Avatar asked Aug 17 '11 19:08

James


1 Answers

There are at least a couple of packages listed in the Python Package Index which deal with intervals:

  • interval

  • pyinterval

I've experimented with interval before and found it to be well-written and documented (at the moment its website seems to be unavailable). I've not used pyinterval.

like image 91
Ned Deily Avatar answered Oct 04 '22 00:10

Ned Deily