Range with floating point steps
examples/iterators/range-with-steps/count.py
import it r = it.Range(1, 6, 2.2) for n in r: print(n)
examples/iterators/range-with-steps/it.py
class Range(): def __init__(self, start, end, step): self.current = start self.end = end self.step = step def __iter__(self): return self def __next__(self): if self.current >= self.end: raise StopIteration v = self.current self.current += self.step return v
1 3.2 5.4
examples/iterators/range-with-steps/test_counter.py
import it def test_range(): r = it.Range(1, 6, 2.2) result = list(r) assert result == [1, 3.2, 5.4]