If you're looking for a Python library that handles intervals arithmetic, consider python-interval. Disclaimer: I'm the maintainer of that library.
This library has support to check for overlaps, and to automatically merge intervals. For example:
>>> import intervals as I
>>> I.closed(1,2) | I.closed(2,3)
[1,3]
>>> I.closed(1,2).overlaps(I.closed(3,4))
False
If you want to specifically compute the overlap:
>>> I.closed(1,3) & I.closed(2, 4)
[2,3]
It supports open/closed intervals, finite or infinite. To remove intervals for a given one, just use the difference operator:
>>> I.closed(1, 4) - I.closed(2, 3)
[1,2) | (3,4]
I can help you if you can be a little bit more specific.