segmentlist_range

igwn_segments.utils.segmentlist_range(start, stop, period)

Analogous to Python’s range() builtin, this generator yields a sequence of continuous adjacent segments each of length “period” with the first starting at “start” and the last ending not after “stop”. Note that the segments generated do not form a coalesced list (they are not disjoint). start, stop, and period can be any objects which support basic arithmetic operations.

Example:

>>> from igwn_segments import *
>>> segmentlist(segmentlist_range(0, 15, 5))
[segment(0, 5), segment(5, 10), segment(10, 15)]
>>> segmentlist(segmentlist_range('', 'xxx', 'x'))
[segment('', 'x'), segment('x', 'xx'), segment('xx', 'xxx')]