# HG changeset patch # User Paul Boddie # Date 1489163238 -3600 # Node ID e89a0ec1549469e948883cf29355dd46ffdc1ad6 # Parent ef0e0f95f50dd9378ff8c640a66378511117e151# Parent 85416087aa62d23e139ed11ed8d871eafbb4eeb6 Merged changes from the default branch. diff -r ef0e0f95f50d -r e89a0ec15494 lib/__builtins__/span.py --- a/lib/__builtins__/span.py Fri Mar 10 15:21:08 2017 +0100 +++ b/lib/__builtins__/span.py Fri Mar 10 17:27:18 2017 +0100 @@ -79,20 +79,19 @@ "Return an iterator, currently self." - return xrangeiterator(self) + return xrangeiterator(self.start, self.step, self.__len__()) class xrangeiterator: "An iterator over an xrange." - def __init__(self, obj): + def __init__(self, start, step, count): "Initialise the iterator with the given 'obj'." - self.start = obj.start - self.count = obj.__len__() - self.step = obj.step - self.current = obj.start + self.current = start + self.step = step + self.count = count def next(self): @@ -102,8 +101,8 @@ raise StopIteration current = self.current - self.current += self.step - self.count -= 1 + self.current = self.current.__add__(self.step) + self.count = self.count.__sub__(1) return current def range(start_or_end, end=None, step=1):